-
Notifications
You must be signed in to change notification settings - Fork 0
/
log-in.php
145 lines (132 loc) · 5.88 KB
/
log-in.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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
<!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.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 main-height">
<?php
$flag = 0;
$username = "";
$password = "";
$usernameErr = "";
$passwordErr = "";
$password_check = "";
if ($_SERVER["REQUEST_METHOD"] == "POST") {
session_start();
include('data-base/constant.php');
$username = $_POST['username'];
$password = $_POST['password'];
$sql = "SELECT * FROM customer_login 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;
$_SESSION['ca-username'] = $username;
}
}
}
if ($flag == 0) {
$usernameErr = "*Invalid username";
}
if ($username == "") {
$usernameErr = "*Fill the username";
}
if ($flag == 1) {
if (md5($password) == $password_check) {
unset($_SESSION['username']);
$_SESSION['customer-id'] = $id;
header('location:index.php?from=logging_in&duration=2500');
} else {
$passwordErr = "*Wrong password";
}
if ($password == "") {
$passwordErr = "*Fill the password";
}
}
}
?>
<?php include('animated/signinphone.html'); ?>
<div class="log-in-body">
<form action="" method="post" name="form">
<label class="text-left" for="username">Username </label>
<span class="label">@customer</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>
<?php
if ($usernameErr == "") {
if ($passwordErr == "*Wrong password") echo "<span class='forgot-password'><a href='forgot-password/ca-fo-pass-otp.php'>forgot password</a></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">
Don't have an account , create one...?
<a class="link-fit-content no-text-decoration" href="customer/ca-phone.php">
sign-in
</a><br>
<span class="small-text">
I am a seller...?
<a class="link-fit-content no-text-decoration small-font" href="log-in-seller.php">log-in</a></span>
<span class="login-margin small-text1">
I am an admin...!
<a class="link-fit-content no-text-decoration small-font1" href="log-in-admin.php">log-in</a></span>
</div>
</div>
</div>
<!--footer-->
<?php include('elements/footer.html') ?>