-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy paththe_head.php
114 lines (60 loc) · 2.42 KB
/
the_head.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
109
110
111
112
113
114
<?php
session_start();
$con = mysqli_connect("localhost", "root","","food");
if(mysqli_connect_errno())
{
echo "Failed to connect: " .mysqli_connect_errno();
}
mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);
$timezone = date_default_timezone_set("America/Chicago");
$newDate = date("m/j/Y \a\\t g:i a");
$registerID = "SELECT id FROM registers";
$re = mysqli_query($con, $registerID);
$row = mysqli_num_rows($re);
$loginID = "SELECT id FROM logins";
$reLogin = mysqli_query($con, $loginID);
$rowLogin = mysqli_num_rows($reLogin);
if(isset($_POST['register_button']))
{
$newId = $row + 1;
$query = mysqli_query($con, "INSERT INTO registers VALUES('".$newId."', '".$_POST['reg_email']."', '".$_POST['reg_password']."')");
header("Location: register_login.php");
}
if(isset($_POST['logout_button']))
{
$_SESSION['username'] = NULL;
header("Location: register_login.php");
}
// if(isset($_POST['login_button']))
// {
// $newLoginId = $rowLogin + 1;
// $query = mysqli_query($con, "INSERT INTO logins VALUES('".$newLoginId."', '".$_POST['log_email']."', '".$_POST['log_password']."')");
// header("Location: register_login.php");
// }
if(isset($_POST['login_button']))
{
$email = filter_var($_POST['log_email'], FILTER_SANITIZE_EMAIL); // sanitize email
$_SESSION['log_email'] = $email; //Store email into session variable
$password = $_POST['log_password']; // Get password
$check_database_query = mysqli_query($con, "SELECT * FROM registers WHERE rEmail = '$email' AND rPassword='$password'");
$check_login_query = mysqli_num_rows($check_database_query);
if($check_login_query > 0)
{
$row = mysqli_fetch_array($check_database_query);
$username = "Correct";
// $user_closed_query = mysqli_query($con, "SELECT * FROM users2 WHERE email='$email' AND user_closed='yes'");
// if(mysqli_num_rows($user_closed_query) == 1)
// {
// $reopen_account = mysqli_query($con, "UPDATE users2 SET user_closed='no' WHERE email='$email'");
// }
$_SESSION['username'] = $username;
// header("Location: register_login.php");
// $_SESSION['log_email'] = "";
// exit();
}
else
{
$_SESSION['username'] = NULL;
}
}
?>