index.php file
<form action = "login.php" method = "POST">
Email or Contact : <input type = "text" name = "user">
Password : <input type = "password" name = "password">
<input type = "submit" value = "Login">
</form>
login.php file
<?php
session_start();
$conn = mysql_connect("localhost","root","");
mysql_select_db("yourdatabase name",$conn);
$user = $_POST['user'];
$password = $_POST['password'];
$sql = mysql_query("select * from user where (email = '$user' or contact = '$user') and password = '$password'");
$result = mysql_fetch_array($sql);
$dbemail = $result['email'];
$dbcontact = $result['contact'];
$dbid = $result['id'];
if($user==$dbemail || $user==$dbcontact)
{
$_SESSION['id']=$dbid;
?>
<script>
window.location='home.php';
</script>
<?php
}
?>
home.php file
<h1>Welcome! You are loggedin now</h1>
<a href = "logout.php">Logout</a>
logout.php file
<?php
session_start();
session_destroy();
?>
<script>
alert("You are logging out now..");
window.location='index.php';
</script>
Choose the right course and start building your future with practical skills.
Learn HTML, CSS, JavaScript, and PHP to build modern, responsive websites and real-world projects.
Enroll Now See Full Details
Understand electronics basics with hands-on breadboard projects and circuit building techniques.
Enroll Now See Full Details
Step into AI with real-world applications, automation tools, and smart development techniques.
Enroll Now See Full Details