-
Notifications
You must be signed in to change notification settings - Fork 0
/
login.php
48 lines (48 loc) · 1.63 KB
/
login.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
<?php
ini_set('display_errors', 'on');
ini_set('log_errors', 'on');
ini_set('display_startup_errors', 'on');
ini_set('error_reporting', E_ALL);
include "connect.php";
//verifying the password and setting session variables for the user
if (isset($_POST['e-mail']) || isset($_POST['password'])) {
$loginemail = $_POST['e-mail'];
$loginpassword = $_POST['password'];
} else {
echo '<script>console.log("Something went wrong!");</script>';
}
$findpass = "SELECT User_Password FROM user_info WHERE Email = '{$loginemail}'";
$result = mysqli_query($conn, $findpass);
$row = mysqli_fetch_assoc($result);
$hash = $row['User_Password'];
$verify = password_verify($loginpassword, $hash);
if ($verify) {
session_start();
$_SESSION["loggedin"] = true;
$_SESSION["userid"] = $loginemail;
$ownerinfo = "SELECT * FROM user_info WHERE Email = '{$_SESSION["userid"]}'";
$result = mysqli_query($conn, $ownerinfo);
$row = mysqli_fetch_row($result);
$ownername = $row[0];
$phone = $row[3];
$dogname = $row[7];
$dogbreed = $row[8];
$dogage = $row[9];
$doggender = $row[10];
$_SESSION["username"] = $ownername;
$_SESSION["phone"] = $phone;
$_SESSION["dogname"] = $dogname;
$_SESSION["dogbreed"] = $dogbreed;
$_SESSION["dogage"] = $dogage;
$_SESSION["doggender"] = $doggender;
echo '<script>console.log("Password verified");
location.href= "http://localhost/ICTWEB517/playdate.php";
</script>';
} else {
echo '<script>console.log("Incorrect password");</script>';
mysqli_close($conn);
echo '<script>alert("Incorrect e-mail or password. Please try again or create an account");
location.href= "http://localhost/ICTWEB517/homepage.php";
</script>';
}
?>