0byt3m1n1
Path:
C:
/
wamp64
/
www
/
WaterCat
/
[
Home
]
File: login.php
<html> <head> <title<login</title> <link rel="stylesheet" type="text/css" href="style.css"> </head> <body background="assets/images/slider/s1.jpg" alt=""> <centre><h1>Login Form </h1> </centre> <?php if(@$_POST['Empty']==true) { ?> <div class="alert-light text-danger text-center my-3"> <?php } ?> <form method="POST" action="#"> <div class="container"> <input type="hidden" value= <?php echo $_GET['id'];?> name="id"> <label>User Name : </label> <input type="text" placeholder="Enter Username" name="username" required> <br> <br> <label>Password : </label> <input type="password" placeholder="Enter Password" name="password" required> <br> <br> <br> <br> <input type="submit" name="login" value="Login"> </div> <p>If Not registered? <a href="reg.php">signup</a> </p> </form> </body> </html> <?php $servername="localhost"; $username="root"; $password=""; $dbname="watercat"; $conn=new mysqli($servername,$username,$password,$dbname); session_start(); $_SESSION['message']="Please Enter Correct Username and Password"; if(isset($_POST['login'])) { if(empty($_POST['username']) || empty($_POST['password'])) { header("location:login.php?Empty=Please fill the form"); } else { $user=$_POST['username']; $pass= $_POST['password']; $query="select * from register where Name='$user' and Password='$pass'"; $result=mysqli_query($conn,$query); $rows=mysqli_fetch_assoc($result); $id=$rows['Id']; $em=$rows['Email']; if(mysqli_fetch_assoc($result)) { $_SESSION['username']=$_POST['username']; $_SESSION['Id']=$_GET['id']; header("location:welcome.php?email=".$em); } else{ echo '<p align="center"><b><font color="red">' .$_SESSION['message'].'</font></b></p>'; unset($_SESSION['message']); } } } ?>