Ask Question - Get Answer

6 Ans PHP log in form code download from here

Asked by Birds of the sky (2 Golds) Thursday, 30 Dec 2021, 07:05 AM at (Technology Computer)

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

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

Answer(s):

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) Thursday, 30 Dec 2021, 07:11 AM

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) Thursday, 30 Dec 2021, 07:10 AM

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) Thursday, 30 Dec 2021, 07:09 AM

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) Thursday, 30 Dec 2021, 07:09 AM

Please log in to Upvote, Downvote and Report

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) Thursday, 30 Dec 2021, 07:08 AM

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) Thursday, 30 Dec 2021, 07:06 AM

Please log in to Upvote, Downvote and Report
           

Related Q/A:

1 Ans What is Disk Defragmentation Used for?

1 Ans Difference between Save and Save As?

6 Ans PHP log in form code download from here

1 Ans What is the name of the first electronic computer?

3 Ans How to remove formatting in word from any pasted text?

2 Ans Which laptop will be best for a computer science and engineering (cse) student? 

1 Ans What is the Internet?

1 Ans Quantum Computer is being brought by Google

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

1 Ans The world's top 5 super computers descriptions