-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
221 lines (184 loc) · 5.44 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
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
<?php
require_once 'php_action/db_connect.php';
session_start();
if(isset($_SESSION['userId'])) {
header('location: http://localhost/stock/dashboard.php');
}
$errors = array();
if($_POST) {
$username = $_POST['username'];
$password = $_POST['password'];
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;
header('location: http://localhost/stock/dashboard.php');
} else{
$errors[] = "Incorrect username/password combination";
} // /else
} else {
$errors[] = "Username doesnot exists";
} // /else
} // /else not empty username // password
} // /if $_POST
?>
<!DOCTYPE html>
<html>
<head>
<title>Stock Management System</title>
<!-- bootstrap -->
<link rel="stylesheet" href="assests/bootstrap/css/bootstrap.min.css">
<!-- bootstrap theme-->
<link rel="stylesheet" href="assests/bootstrap/css/bootstrap-theme.min.css">
<!-- font awesome -->
<link rel="stylesheet" href="assests/font-awesome/css/font-awesome.min.css">
<!-- custom css -->
<link rel="stylesheet" href="custom/css/custom.css">
<!-- jquery -->
<script src="assests/jquery/jquery.min.js"></script>
<!-- jquery ui -->
<link rel="stylesheet" href="assests/jquery-ui/jquery-ui.min.css">
<script src="assests/jquery-ui/jquery-ui.min.js"></script>
<!-- bootstrap js -->
<script src="assests/bootstrap/js/bootstrap.min.js"></script>
<style>
body {
background-image: url('https://www.singerslfiles.com/images/singer-logos/singer_website_logo.png');
background-size: cover;
background-repeat: no-repeat;
background-attachment: fixed;
margin: 0;
font-family: Arial, sans-serif;
}
.panel {
background-color: rgba(255, 255, 255, 0.15);
border: none;
width: 100%;
max-width: 600px; /* Adjust the max-width as needed */
padding: 40px; /* Adjust the padding as needed */
border-radius: 10px;
backdrop-filter: blur(10px);
box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
text-align: center;
}
/* Style for the panel title */
.panel-title {
font-size: 24px;
margin-bottom: 15px;
}
/* Style for the form fields */
.form-group {
margin-bottom: 20px;
}
/* Style for the alert messages */
.alert {
margin-bottom: 15px;
border-radius: 5px;
font-size: 14px;
background-color: rgba(255, 255, 255, 0.5);
padding: 10px;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}
/* Style for the username and password fields */
.form-control {
border: none;
border-radius: 5px;
background-color: rgba(255, 255, 255, 0.5);
backdrop-filter: blur(5px);
padding: 10px;
margin-bottom: 10px;
box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.1);
width: 100%;
}
/* Style for the login button */
.btn-default {
background-color: #ff3333;
border: none;
color: #fff;
border-radius: 5px;
padding: 10px 20px;
font-size: 16px;
transition: background-color 0.3s;
cursor: pointer;
}
/* Style for the login button icon */
.glyphicon-log-in {
margin-right: 5px;
}
/* Change button color on hover */
.btn-default:hover {
background-color: #ff4f4f;
}
/* Center button within form group */
.form-group .btn-default {
margin: 0 auto;
}
</style>
</head>
<body>
<div class="container">
<div class="row vertical">
<div class="col-md-5 col-md-offset-4">
<div class="panel panel-info">
<div class="panel-heading">
<h3 class="panel-title">Login Inventory </h3>
</div>
<div class="panel-body">
<div class="messages">
<?php if($errors) {
foreach ($errors as $key => $value) {
echo '<div class="alert alert-warning" role="alert">
<i class="glyphicon glyphicon-exclamation-sign"></i>
'.$value.'</div>';
}
} ?>
</div>
<form class="form-horizontal" action="<?php echo $_SERVER['PHP_SELF'] ?>" method="post" id="loginForm">
<fieldset>
<div class="form-group">
<label for="username" class="col-sm-2 control-label">Username</label>
<div class="col-sm-10">
<input type="text" class="form-control" id="username" name="username" placeholder="Username" autocomplete="off" />
</div>
</div>
<div class="form-group">
<label for="password" class="col-sm-2 control-label">Password</label>
<div class="col-sm-10">
<input type="password" class="form-control" id="password" name="password" placeholder="Password" autocomplete="off" />
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<button type="submit" class="btn btn-default"> <i class="glyphicon glyphicon-log-in"></i> Login</button>
</div>
</div>
</fieldset>
</form>
</div>
<!-- panel-body -->
</div>
<!-- /panel -->
</div>
<!-- /col-md-4 -->
</div>
<!-- /row -->
</div>
<!-- container -->
</body>
</html>