-
Notifications
You must be signed in to change notification settings - Fork 0
/
log-in-admin.php
131 lines (122 loc) · 4.89 KB
/
log-in-admin.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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
<?php
session_start();
$flag = 0;
$username = "";
$password = "";
$usernameErr = "";
$passwordErr = "";
$password_check = "";
if ($_SERVER["REQUEST_METHOD"] == "POST") {
include('data-base/constant.php');
$username = $_POST['username'];
$password = $_POST['password'];
$sql = "SELECT * FROM admin WHERE username='$username'";
$res = mysqli_query($conn, $sql);
if ($res->num_rows > 0) {
while ($row = $res->fetch_assoc()) {
$id = $row["id"];
$password_check = $row["password"];
if ($row["username"] == $username) {
$flag = 1;
}
}
}
if ($flag == 0) {
$usernameErr = "*Invalid username";
}
if ($username == "") {
$usernameErr = "*Fill the username";
}
if ($flag == 1) {
if (md5($password) == $password_check) {
$_SESSION['admin-id'] = $id;
header('location:admin/manage-seller.php?from=logging_in&duration=2500');
} else {
$passwordErr = "*Invalid password";
}
if ($password == "") {
$passwordErr = "*Fill the password";
}
}
}
?>
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Customer</title>
<link rel="stylesheet" type="text/CSS" href="css/main.css">
<link rel="stylesheet" type="text/CSS" href="css/log-in-admin.css">
<script src="js/responsiveNavigation.js" defer></script>
</head>
<body>
<!-- menu start -->
<nav class="nav-bar" responsiveNavigation=false>
<ul>
<a href="index.php" class="no-text-decoration">
<li class="index ">home</li>
</a>
<a href="search.php" class="no-text-decoration">
<li class="category ">search</li>
</a>
<a href="order.php" class="no-text-decoration">
<li class="order">orders</li>
</a>
<a href="profile.php" class="no-text-decoration">
<li class="profile">profile</li>
</a>
<a href="log-in.php" class="no-text-decoration">
<li class="login highlight">log in</li>
</a>
</ul>
<button class="nav-button"></button>
</nav>
<!-- menu end -->
<!--body-->
<div class="body1 body2">
<div class="log-in-body">
<form action="" method="POST">
<label class="text-left" for="username">Username </label>
<span class="label">@admin</span>
<input class="<?php if ($usernameErr != "") echo 'shake'; ?>" type="text" id="username" name="username" placeholder="phone/email" value="<?php echo $username ?>" /><br>
<span class="error"><?php echo $usernameErr; ?></span>
<br>
<label class="dis" for="password">Password </label>
<div class="forgot-pass-wrap">
<input class="<?php if ($passwordErr != "") echo 'shake'; ?>" id="password" name="password" placeholder="password" value="<?php echo $password; ?>" /><br>
<button type="button" id="eye" class="forgot-pass-img" onclick="forgotPassIcon()"></button>
</div>
<span class="error"><?php echo $passwordErr; ?></span><br>
<input type="submit" id="log-in" value="Log-in" />
</form>
<script>
let status = 1;
document.getElementById("password").setAttribute("type", "password");
document.getElementById("eye").setAttribute("class", "forgot-pass-img");
function forgotPassIcon() {
if (status == 0) {
document.getElementById("password").setAttribute("type", "password");
document.getElementById("eye").setAttribute("class", "forgot-pass-img");
status = 1;
} else {
document.getElementById("password").setAttribute("type", "text");
document.getElementById("eye").setAttribute("class", "forgot-password-click");
status = 0;
}
}
</script>
<div class="padding-CAC">
I am a customer...?
<a class="link-fit-content no-text-decoration" href="log-in.php">
log-in
</a>
<span class="login-margin">I am a seller...?</span>
<a class="link-fit-content no-text-decoration" href="log-in-seller.php">
log-in
</a>
</div>
</div>
<?php include('animated/adminlogin.html'); ?>
</div>
<!--footer-->
<?php include('elements/footer.html') ?>