-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.php
166 lines (128 loc) · 5.1 KB
/
index.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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
<link rel="stylesheet" href="assets/css/popup_style.css">
<style>
.footer1 {
position: fixed;
bottom: 0;
width: 100%;
color: #5c4ac7;
text-align: center;
}
</style>
<?php
include('./constant/layout/head.php');
include('./constant/connect.php');
session_start();
if(isset($_SESSION['userId'])) {
//header('location:'.$store_url.'login.php');
}
$errors = array();
if($_POST) {
$username = $_POST['username'];
$password = $_POST['password'];
//echo $password;exit;
if(empty($username) || empty($password)) {
if($username == "") {
$errors[] = "Username is required";
}
if($password == "") {
$errors[] = "Password is required";
}
} else {
$sql = "SELECT * FROM users WHERE username = '$username'";
$result = $connect->query($sql);
if($result->num_rows == 1) {
$password = md5($password);
// exists
$mainSql = "SELECT * FROM users WHERE username = '$username' AND password = '$password'";
$mainResult = $connect->query($mainSql);
if($mainResult->num_rows == 1) {
$value = $mainResult->fetch_assoc();
$user_id = $value['user_id'];
// set session
$_SESSION['userId'] = $user_id;?>
<div class="popup popup--icon -success js_success-popup popup--visible">
<div class="popup__background"></div>
<div class="popup__content">
<h3 class="popup__content__title">
Success
</h1>
<p>Login Successfully</p>
<p>
<?php echo "<script>setTimeout(\"location.href = 'dashboard.php';\",1500);</script>"; ?>
</p>
</div>
</div>
<?php }
else{
?>
<div class="popup popup--icon -error js_error-popup popup--visible">
<div class="popup__background"></div>
<div class="popup__content">
<h3 class="popup__content__title">
Error
</h1>
<p>Incorrect username/password combination</p>
<p>
<a href="login.php"><button class="button button--error" data-for="js_error-popup">Close</button></a>
</p>
</div>
</div>
<?php } // /else
} else { ?>
<div class="popup popup--icon -error js_error-popup popup--visible">
<div class="popup__background"></div>
<div class="popup__content">
<h3 class="popup__content__title">
Error
</h1>
<p>Username doesnot exists</p>
<p>
<a href="login.php"><button class="button button--error" data-for="js_error-popup">Close</button></a>
</p>
</div>
</div>
<?php } // /else
} // /else not empty username // password
} // /if $_POST
?>
<div id="main-wrapper">
<div class="unix-login">
<div class="container-fluid" style="background-image: url('./assets/uploadImage/Logo/banner3.jpg');
background-position: center;
background-repeat: no-repeat;
background-size: cover;">
<div class="row ">
<div class="col-lg-4">
<div class="login-content">
<div class="login-form">
<center><img src="./assets/uploadImage/Logo/logo.jpg" style="width: 100%;"></center><br>
<form action="<?php echo $_SERVER['PHP_SELF'] ?>" method="post" id="loginForm">
<div class="form-group">
<label lass="col-sm-3 control-label">Username</label>
<input type="text" name="username" id="username" class="form-control" placeholder="Username" required="">
</div>
<div class="form-group">
<label>Password</label>
<input type="password" id="password" name="password" class="form-control" placeholder="Password" required="">
</div>
<div class="forgot-phone col-md-12 text-right">
<a href="#" class="text-right f-w-600 text-white"> Forgot Password?</a>
</div>
<button type="submit" name="login" class=" f-w-600 btn btn-white btn-flat m-b-30 m-t-30" style="background-color: #da0000; color: white">Sign in</button>
</form>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<script src="./assets/js/lib/jquery/jquery.min.js"></script>
<script src="./assets/js/lib/bootstrap/js/popper.min.js"></script>
<script src="./assets/js/lib/bootstrap/js/bootstrap.min.js"></script>
<script src="./assets/js/jquery.slimscroll.js"></script>
<script src="./assets/js/sidebarmenu.js"></script>
<script src="./assets/js/lib/sticky-kit-master/dist/sticky-kit.min.js"></script>
<script src="./assets/js/custom.min.js"></script>
</body>
</html>