Ask Question - Get Answer

6 Ans PHP log in form code download from here

Asked by Birds of the sky (2 Golds) Wednesday, 29 Dec 2021, 08:05 PM at (Technology Computer)

Please log in to answer, like and save
0
Save 0

<<< Previous
Log in to Answer Next >>>

Answer(s):

config.php  ( Database Connection and Configuration File )

<?php

if (session_status() == PHP_SESSION_NONE) {
    session_start();
}

$server = "localhost";
$user = "root";
$pass = "";
$dbname = "bpsc";
$conn = mysqli_connect($server, $user, $pass, $dbname);
if ($conn) {
    //echo 'Connected';
}

/* At first Create Table with this Query 
CREATE TABLE `test` (
 `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
 `name` varchar(255) NOT NULL,
 `password` varchar(255) NOT NULL,
 `dob` date NOT NULL,
 UNIQUE KEY `id` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=latin1
 * 
 */

Answered by Birds of the sky (2 Golds) Wednesday, 29 Dec 2021, 08:08 PM

Please log in to Upvote, Downvote and Report

PHP login form creation is very easy. Just copy and paste this on your IDE (Ex: Netbeans...) and XAMPP , MYSQL etc and get output.

Thanks.  

Answered by Birds of the sky (2 Golds) Wednesday, 29 Dec 2021, 08:06 PM

Please log in to Upvote, Downvote and Report

index.php file


<?php

include_once 'config.php';

?>

<html>

    <head>

        <title>

            PHP LOG IN FORM

        </title>

    </head>

    <body>

        

        <a href="index.php"> Add Data </a> <br>

        <a href="login.php"> Log In Data </a> <br>

        <a href="logout.php"> Log Out </a> <br>

         

        

        <h2> Add Data into Database </h2>

        <form method="POST" action="action.php" enctype="multipart/form-data">

            <input type="text" name = "name" placeholder="Enter Name"/>

            <input type="password" name = "password" placeholder="Enter Password"/>

            <input type="date" name="dob"/>

            <input type="submit" name="submit" value="Add Data"/>

        </form>


        <br>

        <br>

    </body>

</html>

<?php

?>

Answered by Birds of the sky (2 Golds) Wednesday, 29 Dec 2021, 08:09 PM

Please log in to Upvote, Downvote and Report

action.php (Data is inserted by this page)

<?php

include_once 'config.php';

?>

<a href="index.php"> Add Data </a> <br>

<a href="login.php"> Log In Data </a> <br>

<a href="logout.php"> Log Out </a> <br>

<?php

if (isset($_POST['submit']) & !empty($_POST['submit'])) {

    $sql = "INSERT INTO test(name, password, dob) VALUES('$_POST[name]', '$_POST[password]', '$_POST[dob]')";

    if (mysqli_query($conn, $sql)) {

        echo 'Data Inserted Successfully! ';

    }

}

Answered by Birds of the sky (2 Golds) Wednesday, 29 Dec 2021, 08:09 PM

Please log in to Upvote, Downvote and Report

login.php

<?php
include_once 'config.php';
?>
<a href="index.php"> Add Data </a> <br>
<a href="login.php"> Log In Data </a> <br>
<a href="logout.php"> Log Out </a> <br>
<?php
if (isset($_POST['submit']) & !empty($_POST['submit'])) {
    $sql = "SELECT * FROM test WHERE name = '$_POST[name]' AND dob = '$_POST[dob]'";
    $result = mysqli_query($conn, $sql);
    if ($result) {
        if ($row = mysqli_fetch_assoc($result) > 0) {
            $name = $row['name'];
            $pass = $row['password'];
            $dob = $row['dob'];

            $_SESSION['logged'] = 'yes';

            echo 'Logged in successfully!';
            echo $name;
            echo $pass;
            echo $dob;
        } else {
            echo 'Name, Password, DOB not Matched! ';
        }
    }
}
?>
<h2> Log In Database </h2>
<form method="POST" action="login.php" enctype="multipart/form-data">
    <input type="text" name = "name" placeholder="Enter Name"/>
    <input type="password" name = "password" placeholder="Enter Password"/>
    <input type="date" name="dob"/>
    <input type="submit" name="submit" value="Log In"/>
</form>
<?php

Answered by Birds of the sky (2 Golds) Wednesday, 29 Dec 2021, 08:10 PM

Please log in to Upvote, Downvote and Report

logout.php file


<?php

include_once 'config.php';

?>

<a href="index.php"> Add Data </a> <br>

<a href="login.php"> Log In Data </a> <br>

<a href="logout.php"> Log Out </a> <br>

<?php

if(session_destroy())

{

    echo 'Logged Out Successfully! ';

}


?>


Answered by Birds of the sky (2 Golds) Wednesday, 29 Dec 2021, 08:11 PM

Please log in to Upvote, Downvote and Report
           

Related Q/A:

1 Ans How to create a folder without name and icon in Computer?

1 Ans What does the word computer mean?

1 Ans Difference between Save and Save As?

3 Ans How can I stop office click to run service, it starts automatically at startup[office 2019 nd  w10].

1 Ans Why happened if I capture picture on mobile it's right and left not positioned accurately?

1 Ans What can be done with Python?

1 Ans Adobe Acrobat 2016 and Adobe Reader 2015 tools are going to be stopped

3 Ans NESCO Assistant Manager (ICT) full Question with solution 2021 Exam Taker BUET on 31 December, 2021

1 Ans How to become a computer hacker?

1 Ans 100 most important shortcut key of Microsoft Windows


AL MaMun (active on Monday, 06 Sep 2021, 11:15 AM) (4 Golds)
Birds of the sky (active on Wednesday, 27 Apr 2022, 12:16 PM) (2 Golds)
Tajrimun Elisha (active on Friday, 22 Nov 2019, 08:56 AM) (2 Golds)
Ghost (active on Saturday, 05 Jan 2019, 10:37 AM) (1 Silver)
Hena Begum (active on Friday, 15 Feb 2019, 11:04 PM) (8 Bronzes)
BrandonDug (active on Thursday, 17 Dec 2020, 05:25 AM) ( New Contributor )
Md Hasan (active on Saturday, 02 Nov 2019, 10:02 AM) (4 Bronzes)
APU KUMAR ROY (active on Sunday, 22 Sep 2019, 02:42 AM) (1 Bronze)
عبد الحنان سلفي (active on Friday, 28 Aug 2020, 05:04 PM) (2 Bronzes)
student (active on Monday, 27 Jul 2020, 07:28 PM) (2 Bronzes)
Jackson99 (active on Monday, 27 Apr 2020, 02:44 PM) ( New Contributor )
Hr Hannan (active on Tuesday, 11 Dec 2018, 12:28 PM) (2 Bronzes)
Miskatul Zannat Bristy (active on Friday, 16 Jul 2021, 02:08 AM) ( New Contributor )
Bongiyo Training (active on Wednesday, 30 Mar 2022, 02:57 PM) ( New Contributor )
G. M. Nasir Uddin Ahammad (active on Tuesday, 08 Mar 2022, 01:50 PM) (2 Bronzes)
MD SAIFUL ISLAM (active on Friday, 24 Jan 2020, 04:13 PM) ( New Contributor )
Daily Science (active on Friday, 03 Jan 2020, 07:52 PM) ( New Contributor )
Md Mondol (active on Tuesday, 23 Jul 2019, 10:28 PM) (2 Bronzes)
Hazrat (active on Sunday, 26 May 2019, 05:55 AM) (2 Bronzes)
Sowrov (active on Thursday, 14 Feb 2019, 10:48 AM) (7 Bronzes)
Show All Members

Online Now 3
Today's Unique PageViews 161
Today's Total PageViews 3672
Site's Total PageViews 3900060