-
Notifications
You must be signed in to change notification settings - Fork 0
/
logincheck.php
31 lines (25 loc) · 900 Bytes
/
logincheck.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
<?php
$conn = new mysqli("localhost", "root","","project");
if($conn->connect_error){
die("connection error");
}
$email = $_POST['email'];
$password = $_POST['password'];
$login_query = "select * from details where email='$email'and password ='$password'";
$login_result = $conn->query($login_query);
// if(mysqli_num_rows($login_result)>0){
// $_SESSION['login']=$_POST['email'];
// echo "<script> document.location = 'dashboard.php';</script>";
// }else{
// echo '<script>alert("User email or password is invalid"); window.location.href = "login.php"</script>';
// }
$loggedin = false;
while($row = $login_result->fetch_assoc()){
$loggedin = true;
}
if($loggedin == true){
echo "<script> document.location = 'welcome.php?email=$email';</script>";
}else{
echo '<script>alert("User email or password is invalid"); window.location.href = "login.php"</script>';
}
?>