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 1

<<< 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 can be done with Python?

1 Ans What does the word computer mean?

0 Ans PC Hardware Wholesalers in India: Where to Buy in Bulk for Your Business For businesses looking to procure PC components in bulk, working with PC hardware wholesalers in India offers significant advantages. Buying in large quantities not only ensures better pricing but also simplifies the procurement process. India’s leading wholesalers, including LMN Hardware Supplies and OPQ Distributors, provide an extensive range of PC components such as motherboards, CPUs, RAM, storage devices, and peripherals. These wholesalers source components directly from trusted manufacturers, offering high-quality products at competitive prices. Bulk purchasing can be particularly beneficial for organizations that need to equip offices, data centers, or IT service providers with the necessary hardware. In addition to cost savings, these wholesalers also offer flexible delivery options and customer support services, making them a preferred choice for large-scale operations. For businesses, the key to success is establishing long-term relationships with reliable wholesalers. With the growing demand for IT infrastructure in India, these wholesalers continue to provide excellent products and services to meet the market’s needs. More Info = https://www.bitboxpc.com/computer-pc-hardware-companies-in-india/

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

2 Ans What is a computer?

1 Ans 5 Best Websites to download Free Stock Images!

1 Ans Write about various operating systems of Computer?

1 Ans Difference between Save and Save As?

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

1 Ans What is the function of RAM?