Login page in php ,mysql using using html form (source code)

Login page in php ,mysql using using html form

The  source code of login page in html using php and mysql connection is given below.


<?php
session_start();
include("connection.php");

?>
<form acion="" method="POST">
Username: <input type="text" name="username" value=""/><br><br>
Password: <input type="password" name="password" value=""/><br><br>
<input type="submit" name="submit" value="login"/>
</form>
<?php
if(isset($_POST['submit']))
{
$user=$_POST['username'];
$pwd=$_POST['password'];
$query="SELECT *FROM STUDENT WHERE username='$user' && password='$pwd'";
$data=mysqli_query($conn,$query);
$total=mysqli_num_rows($data);
if( $total==1)
{ $_SESSION['user_name']=$user;
header('location:home.php');
}
else{
echo "login failed";
}
}

?>

Comments

Popular posts from this blog

how to compile multiple file in java using single command

Ternary operator and Nested Ternary operator

How to pass argument in main function of java program using command line argument