-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCheckUser.php
108 lines (92 loc) · 3 KB
/
CheckUser.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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
<!DOCTYPE html>
<!-- author, date, project description-->
<html>
<head>
<title>The Local Theatre successful login</title>
<link rel="stylesheet" type="text/css" href="stylesheet.css"/>
</head>
<body>
<header>
<h1>The Local Theatre</h1>
</header>
<?php
include("../../DbConnect.php"); // Add in the database connection details
session_start();
// Now get the information from the Form
$Email = $_POST['email'];
$Password = $_POST['password'];
$_SESSION["error"] ='You have entered incorrect email or password';
$stmt = $conn->stmt_init();
if($stmt->prepare("SELECT user_id,surname,email,password,admin,suspended FROM t_users
WHERE email= ?"))
{
$stmt->bind_param('s',$Email);
$stmt->execute();
$stmt->bind_result($user_id,$surname,$email,$password,$admin,$suspended);
if($stmt->fetch())
{
session_start();
$_SESSION["valid"] = 'True';
$_SESSION["user_id"] = $user_id;
$_SESSION["surname"] = $surname;
$_SESSION["email"] = $email;
$_SESSION["admin"] = $admin;
$_SESSION["suspended"] = $suspended;
// Set the cookie
setcookie("user_email", $email, time() + (86400 * 30), "/"); // Cookie will expire after 30 days
// Check if the cookie is set
if(isset($_COOKIE["user_email"])) {
echo "Cookie is set!";
} else {
echo "Cookie is not set!";
}
echo "<script type='text/javascript'>
alert('Your $email ! password is $Password');
<?php include('regUser.php'); ?>
<?php include('admin.php'); ?>
<?php include('SignUp.php'); ?>
</script>";
if(password_verify($Password, $password))
{
if ($_SESSION["suspended"]=='Y'){
echo 'Account Verified '.$Email;
echo "<script type='text/javascript'>
alert('This account is suspended');
window.location.href='SignUp.php';
</script>";
}
elseif($_SESSION["admin"]=='N'){
echo 'Password Verified '.$Email;
echo "<script type='text/javascript'>
alert('The password is correct');
window.location.href='regUser.php';
</script>";
// header("Location: regUser.php");
}
elseif($_SESSION["admin"]=='Y'){
echo 'Password Verified '.$Email;
echo "<script type='text/javascript'>
alert('The password is correct');
window.location.href='admin.php';
</script>";
}
}
else {
echo "<script type='text/javascript'>
alert('Unsuccessful Login. Try again!');
window.location.href='Login.php';
</script>";
// header("Location: Login.php");
}
}else
{
echo 'Unrecognised login details';
header("Location: Login.php");
}
}else{
echo 'Prepared statement is broken';
}
$stmt->close();
?>
</body>
</html>