-
Notifications
You must be signed in to change notification settings - Fork 0
/
adminlogin.php
110 lines (87 loc) · 2.42 KB
/
adminlogin.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
<?php
session_start();
?>
<?php require_once('connection.php'); ?>
<?php
//check for form submission
if (isset($_POST['submit'])) {
$errors = array();
//check if the username and password has been entered
//if (!isset($_POST['userName']) || strlen(trim($_POST['username'])) < 1){
//$errors[] = "username is missing or invalid";
}
//if (!isset($_POST['password']) || strlen(trim($_POST['password'])) < 1){
//$errors[] = "password is missing or invalid";
//check if there are any errors in the form
//if(empty($errors)){
//$username = $_SESSION['username'] ;
//save username and password into variables
$username = mysqli_real_escape_string($connection,$_POST['userName']);
$password = mysqli_real_escape_string($connection,$_POST['password']);
// $hashed_password = sha1($password);
//prepare database query
$query = "SELECT *FROM admin
WHERE username = '{$username}'
AND password = '{$password}'
LIMIT 1";
$result_set = mysqli_query($connection,$query);
if ($result_set){
//query succesfull
if(mysqli_num_rows($result_set) == 1){
//valid user found
$user = mysqli_fetch_assoc($result_set);
$_SESSION['user_ID'] = $user['customer_ID'];
echo $user;
//redirect to users.php
header('Location: AdminDashboard.php');
}else{
//user name and password invalid
$errors[] = 'Invalid username or password';
}
}else{
$errors[] = 'database query failed';
}
}
}
?>
<html>
<head>
<link rel="stylesheet" type="text/css" href="styles/home.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.9.0/css/all.css">
<title>Admin Login From</title>
<link rel="stylesheet" type="text/css" href="styles/login2.css">
<script src="js/adminlogin.js"></script>
</head>
<body background="pictures/background.jpg">
<img src="pictures/56.png" width="350" height="150">
<hr>
<div class="image">
<center>
<h1>Admin Login Form</h1>
</center>
<br>
<br>
<br>
<br>
<!--user login begins-->
<center>
<div class="login">
<img src="pictures/login.png" class="avatar1">
<h1>
Login Here
</h1>
<form>
<p>User Name</p>
<input type = "text" id="user" placeholder="Enter Username">
<P>Password</p>
<input type = "password" id="pwd" placeholder="Enter Password">
<a href="#">Forget Your Password?</a><br>
<input type="submit" name="" value="Login" onclick="validateForm()">
</form>
</div>
</center>
<!--user login ends-->
</div>
<hr>
</body>
</html>