-
Notifications
You must be signed in to change notification settings - Fork 0
/
verify.php
50 lines (42 loc) · 1008 Bytes
/
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 is Not Activated!';
}
}
else{
$_SESSION['error'] = 'This Email is Not Found!';
}
}
catch(PDOException $e){
echo "There is Some Problem in Connection: " . $e->getMessage();
}
}
else{
$_SESSION['error'] = 'Please Input Data Correctly!';
}
$pdo->close();
header('location: login.php');
?>