-
Notifications
You must be signed in to change notification settings - Fork 0
/
authCheck.php
38 lines (28 loc) · 839 Bytes
/
authCheck.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
<?php
session_start();
$email = $_POST['email'];
$password = $_POST['password'];
//Open a new connection to the MySQL server
$mysqli = new mysqli('localhost', 'root', '', 'flowercafeandshop');
//Output any connection error
if ($mysqli->connect_error) {
die('Error : (' . $mysqli->connect_errno . ') ' . $mysqli->connect_error);
}
$query = "SELECT * FROM members WHERE email='$email'";
$result = mysqli_query($mysqli, $query) or die(mysqli_error());
$num_row = mysqli_num_rows($result);
$row = mysqli_fetch_array($result);
if ($num_row >= 1) {
if (password_verify($password, $row['password'])) {
$_SESSION['login'] = $row['id'];
$_SESSION['fname'] = $row['fname'];
$_SESSION['lname'] = $row['lname'];
echo 'true';
}
else {
echo 'false';
}
} else {
echo 'false';
}
?>