<?php
include 'conn.php';
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Bookstore</title>
<link rel="stylesheet" href="css/bootstrap.min.css">
</head>
<body>
<!-- contact section -->
<section id="contact" class="py-5 bg-warning mt-3">
<div class="container">
<!-- title contact -->
<!-- title -->
<div class="row">
<div class="col text-center ">
<h1 class="display-4 text-uppercase mb-0 ">
<strong>User Login </strong>
</h1>
<div class="title-underline bg-danger"></div>
<!-- <p class="mt-2 text-capitalize text-muted">Lorem ipsum dolor sit amet.</p> -->
</div>
</div>
<!-- end of title -->
<div class="row justify-content-center">
<div class="col-md-6 my-3">
<div class="card card-body bg-secondary">
<!-- title -->
<div class="card-title text-center text-white">
<h1 class="text-capitalize">Sign In here</h1>
<!-- <p>Message Us</p> -->
</div>
<!-- end of title -->
<form action="" method="POST" >
<!-- simple form -->
<div class="form-group mt-3">
<input type="text" class="form-control" name="u_name" placeholder="Username">
</div>
<!-- email -->
<div class="form-group mt-3">
<input type="password" class="form-control " name="u_pass" placeholder="password">
</div>
<!-- append -->
<button type="submit" name="u_login" class="btn btn-outline-dark btn-block text-uppercase">submit</button>
</form>
</div>
</div>
<script src="js/jquery.min.js"></script>
<script src="js/bootstrap.min.js"></script>
<?php
if(isset($_POST['u_login'])) {
$uname = $_POST['u_name'];
$upass = ($_POST['u_pass']) ;
$sql = "SELECT *FROM users WHERE uname ='$uname'";
$result = mysqli_query($conn ,$sql);
if(mysqli_num_rows($result)>0) {
while ($user = mysqli_fetch_assoc($result)){
if($uname == $user['uname'] && $upass ==$user['pass']){
$_SESSION['u_name'] = $uname;
// header('Location:dash.php');
echo "<script type = \"text/javascript\">
alert(\"login Succesfully \");
window.location = (\"dash.php\")
</script>";
}else{
echo "<script>alert('wrong password or Username');</script>";
}
}
} else{
echo 'invalid username';
}
}
?>
</body>
</html>
0 Comments