<!-- at first you need to have data in your database -->
<!-- then match the data with your user's data which will come from input fields -->
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha3/dist/css/bootstrap.min.css" rel="stylesheet">
</head>
<body>
<h1 align="center">Login</h1>
<form class="container card card-body mt-5" action="" method="POST">
<div class="mb-3">
<div>
<label for="exampleInputEmail1" class="form-label">Email</label>
<input type="email" name="email" class="form-control">
</div>
<div>
<label for="exampleInputEmail1" class="form-label">Password</label>
<input type="password" name="password" class="form-control">
</div>
<button type="submit" class="btn btn-primary mt-3">Submit</button>
</form>
</body>
</html>
<?php
require_once ('db.php');
$db = $conn->query('SELECT * FROM `login`');
$r = $db->fetch_assoc();
// print_r ($r);
echo '</br>';
if(isset($_POST['email']) && $_POST['password']){
if(!empty($_POST['password']) && !empty($_POST['email'])){
$email = $_POST['email'];
$password = $_POST['password'];
if($r['email'] === $email && $r['password'] === $password){
echo "<h3 align='center'><font color='green'> Hurray! You Have Loged in Successfully </h3>";;
}else{
echo "<h3 align='center'><font color='red'> Please cheak the fields again! </h3>";
}
}else{
echo "<h3 align='center'><font color='red'> All fields are require!</h3>";
}
}
?>
Post a Comment