-
Notifications
You must be signed in to change notification settings - Fork 4
/
verify.php
50 lines (42 loc) · 1.02 KB
/
verify.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
<?php
include 'includes/session.php';
$conn = $pdo->open();
if(isset($_POST['login'])){
$email = $_POST['email'];
$password = $_POST['password'];
try{
$stmt = $conn->prepare("SELECT *, COUNT(*) AS numrows FROM users WHERE email = :email");
$stmt->execute(['email'=>$email]);
$row = $stmt->fetch();
if($row['numrows'] > 0){
if($row['status']){
if(password_verify($password, $row['password'])){
if($row['type']){
$_SESSION['admin'] = $row['id'];
}
else{
$_SESSION['user'] = $row['id'];
}
}
else{
$_SESSION['error'] = 'Incorrect Password';
}
}
else{
$_SESSION['error'] = 'Account not activated.';
}
}
else{
$_SESSION['error'] = 'Email not found';
}
}
catch(PDOException $e){
echo "There is some problem in connection: " . $e->getMessage();
}
}
else{
$_SESSION['error'] = 'Input login credentails first';
}
$pdo->close();
header('location: login.php');
?>