PHP Programming

PHP is open source programming language. It is server-side scripting language. It is used to handle back-end issues in website. It is used in many website for establishing client - server relationship. It is used for handling database query.

Lets learn how to create login form  and its functionality.

In login form application we are going to learn how to validate form using database query. Here we are going to use SELECT query with WHERE condition to check valid user.

Welocme to login form

UserId

Password

 New User SignUp Here...

 HTML code for login form. lofin.html file contain following code:

<!DOCTYPE html>

<html>

<head><title>Login Form</title></head>

<body>

<h1>Welcome to login form</h1>

<form action="login.php"  method="POST">

<h1>Welcome to login form</h1>

UserId<input type ="text" name="UserId"><br><br>

password<input type="password" name="Password"><br>

<input type="submit" name="submit" value="login">

<a href="signup.html">New User SignUp Here </a>

</body>

</html>  

PHP code for login form. login.php file contain following code:

<?php
$conn = new mysqli('localhost', 'root', ' ','database_name');
    if(isset($_POST['submit']))
    {
        $userid = $_POST['UserId'];
        $password = $_POST['Password'];
        $sql = "SELECT * FROM login WHERE UserId='$userid' and Password='$Password'";
        $result = mysqli_query($conn, $sql);
        $row =  mysqli_fetch_array($result);
            $dbuserid = $row['UserId'];
            $bdpassword = $row['Password'];
        if($userid = = $dbuserid && $password = =  $dbpassword)
        { 
                echo"you are registered user ";
        }
        else
         {
                 echo "please register";
          }
    }
?>


  

Comments

Popular posts from this blog

Python