-
Notifications
You must be signed in to change notification settings - Fork 0
/
signin.php
46 lines (32 loc) · 1.2 KB
/
signin.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
<?php
$conn = new mysqli('localhost', 'root', '', 'daycaredb');
if (isset($_POST['log'])) {
$userID = $_POST['userID'];
$password = $_POST['password'];
$password = md5($password);
$query = "SELECT * FROM parent WHERE u_ID=? AND u_password=? LIMIT 1";
$stmt = $conn->prepare($query);
$stmt->bind_param('is', $userID, $password);
if ($stmt->execute()) {
$result = $stmt->get_result();
$user = $result->fetch_assoc();
//$stmt->close();
if ($user['verified'] == 1) {
$_SESSION['userID'] = $user['userID'];
$_SESSION['message'] = 'You are logged in!';
$_SESSION['type'] = 'alert-success';
header('location: userprofile.php');
exit(0);
}
else
echo "Email is not verified";
}
else { // if password does not match
$errors['login_fail'] = "Wrong userID / password";
}
}
else {
$_SESSION['message'] = "Database error. Login failed!";
$_SESSION['type'] = "alert-danger";
}
?>