/
check.php
executable file
·86 lines (65 loc) · 1.59 KB
/
check.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
<?php
session_start();
require 'classes/users.php';
$errors = [];
if(isset($_POST['ok'])) {
if(!isset($_POST['email']) || empty(trim($_POST['email']))){
$errors[] = "Please, Enter a valid email";
}
if(!isset($_POST['password']) || empty(trim($_POST['password'])))
{
$errors[] = "Please, Enter a valid password";
}
else
{
$user = new Users;
$is_exist = $user->checkBeforeLogin($_POST['email'],$_POST['password']);
if(!$is_exist)
{
$errors[]="email or password is invalid";
}
else
{
}
}
if(!empty($errors))
{
$_SESSION['errors'] = $errors;
echo "<meta http-equiv='Refresh' content='0;url=login.php' />";
}
else
{
$user = new Users();
$user->getUser($_POST['email'],$_POST['password']);
$_SESSION['user_id'] = $user->id;
/*********** check admin my work ************/
$admin = $user->check_admin($_POST['email'],$_POST['password']);
$result= $user->get_id($_POST['email'],$_POST['password']);
if ($admin)
{
echo "<meta http-equiv='Refresh' content='1;url=admin/index.php' />";
}
else
{
// $result=$user->lock_search($result);
// foreach ($result as $key => $value)
// {
// if ($value)
// {
// $errors[]="sorry ^_^ Username and password is Lock ";
// }
// else
// {
echo "<meta http-equiv='Refresh' content='1;url=home.php' />";
// }
// }
}
/*********** check admin my work ************/
die();
}
}
else
{
header("location:login.php");
}
?>