How to create login form in php | complete code for login form in html php
<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8'>
<meta http-equiv='X-UA-Compatible' content='IE=edge'>
<title>Log in </title>
<meta name='viewport' content='width=device-width, initial-scale=1'>
<link rel='stylesheet' type='text/css' media='screen' href='style.css'>
<script src="./javascript.js"></script>
</head>
<body>
<div>
<nav>
<img src="./Images/demPLOGO.gif" class="img" alt="logo">
<ul>
<li><a href="home.html">Home</a></li>
<li><a href="About us .html">About</a></li>
<li><a href="RegisterUser.php"> Register </a></li>
<li><a href="Login.php">Signin</a></li>
<li><a href="Contact us.html">Contact</a></li>
</ul>
</nav>
<div>
<center>
<form action="" method ="POST" >
<table>
<caption><h2>Log in Here </h2></caption>
<tr><td><input type="email" name="email" placeholder="Enter Email Address"></td></tr>
<tr> <td><input type="text" name="pass" id="" placeholder="Enter Password"></td></tr>
<tr><td colspan="2"><button type="submit" name="submit">Login</button>
<a href="RegisterUser.php"style="float:right">Don't have Account? Create Account !!!</a></td></tr>
<tr><td><a href="forgotPassword.php">Forgot Password</a></td></tr>
</table>
</form>
</center>
</div>
</div>
<br><br><br>
<?php
include ('Dbconnection.php');
include('session.php');
if(isset($_POST['submit']))
{
$check = 0;
$email=$_POST['email'];
$password=$_POST['pass'];
$mysql=mysqli_query($con,"SELECT * FROM `userregistration` ");
if($password=="" || $email=="" )
{
echo"<script type=text/javascript>alert('All Fields Are Required!!!');</script> ";
}
else if(mysqli_num_rows($mysql) > 0)
{
while($row = mysqli_fetch_assoc($mysql))
{
if($email!=$row['Email'] && $password!=$row['Pasword'])
{
?>
<script> alert ("Email Or Password is Wrong ")
window.location.href ="Login.php";
</script>
<?php
}
else if($email==$row['Email'] && $password==$row['Pasword'])
{
$check = 1;
?>
<script> alert ("Welcome Dear You are loggin successfuly ")
window.location.href ="home.html";
</script>
<?php
break;
}
}
}
mysqli_close($con);
}
include ('footer.php');
?>
</body>
No comments:
Post a Comment