-
Notifications
You must be signed in to change notification settings - Fork 0
/
handler.php
47 lines (38 loc) · 1.39 KB
/
handler.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
<?php
session_start();
include("account.php");
include("loginfunctions.php");
//DB Connection
$db = mysqli_connect($hostname, $username, $password, $project);
if (mysqli_connect_errno())
{ echo "Failed to connect to MySQL: " . mysqli_connect_error();
exit();
}
print "Successfully connected to MySQL.<br>";
mysqli_select_db($db,$project);
$delay = 3;
//get data
getData("email", $email);
getData("pass", $pass);
//check to see if data is good
if ($bad) exit("Bad Data");
//hash password
$pass = md5($pass);
if (!auth($email, $pass, $t, $reset)){
redirect("<span style=\"color:red;\">Incorrect Credentials...Redirecting...</span>", "/vr/index.html", $delay);
}
//only get here if youre authenticated
$_SESSION["logged"] = true;
$_SESSION["email"] = $email;
//store first and last name
$row = mysqli_fetch_array($t,MYSQLI_ASSOC);
$_SESSION["firstname"] = $row["firstname"];
$_SESSION["lastname"] = $row["lastname"];
//redirect to dashboard
if ($reset){
redirect("<span style=\"color:green;\">You have successfully logged in... Please reset your password now.</span>", "/vr/changepassword.php", $delay);
}
else{
redirect("<span style=\"color:green;\">You have successfully logged in...</span>", "/vr/dashboard.php", $delay);
}
?>