LOGIN PAGE
LOGIN.PHP
<?php
include 'conn.php';
session_start();
if (isset($_SESSION['username'])) {
header("Location: list.php");
}
if (isset($_POST['submit'])) {
$email = $_POST['email'];
$password = $_POST['password'];
$sql = "SELECT * FROM ab WHERE email_id='$email' AND `password`='$password'";
$result = mysqli_query($db,$sql);
if (mysqli_num_rows($result) > 0) {
$row = mysqli_fetch_assoc($result);
$_SESSION['username'] = $row['fullname'];
header("Location: list.php");
} else {
echo "<script>alert('Woops! Email or Password is Wrong.')</script>";
}
}
?>
<!DOCTYPE html>
<html>
<head>
<h1>Login</h1>
</head>
<body>
<form action="" method="POST" class="login-email">
Email id: <span style="color:red">*</span><input type="email" placeholder="Email" name="email" required><br><br>
<span id="" style="color:red"></span>
Password: <span style="color:red">*</span><input type="password" placeholder="Password" name="password" required><br><br>
<span id="" style="color:red"></span>
<button name="submit" class="btn">Login</button>
<p class="login-register-text">Don't have an account? <a href="register.php">Register Here</a>.</p>
</form>
</body>
</html>
Comments
Post a Comment