-
Notifications
You must be signed in to change notification settings - Fork 1
/
login-code.php
54 lines (39 loc) · 1.59 KB
/
login-code.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
51
52
53
54
<?php
require 'config/function.php';
if(isset($_POST['login']))
{
$email = validate($_POST['email']);
$password = validate($_POST['password']);
if($email != '' && $password != ''){
$query = "SELECT * FROM admins WHERE email='$email' LIMIT 1";
$result = mysqli_query($conn,$query);
if($result){
if(mysqli_num_rows($result) == 1){
$row = mysqli_fetch_assoc($result);
$hashedPass = $row['password'];
if(!password_verify($password,$hashedPass)){
redirect('login.php','Invalid password!');
}
if($row['is_ban'] == 1){
redirect('login.php','Your account has been banned. Contact your Admin.');
}
// Session data will store here
$_SESSION['loggedIn'] = true;
$_SESSION['loggedInUser'] = [
'user_id' => $row['id'],
'name' => $row['name'],
'email' => $row['email'],
'phone' => $row['phone'],
];
redirect('admin/index.php','Logged In Successfully');
}else{
redirect('login.php','Invalid email address!');
}
}else{
redirect('login.php','Something went wrong');
}
}else{
redirect('login.php','All fields are mandetory');
}
}
?>