-
Notifications
You must be signed in to change notification settings - Fork 3
/
index.php
205 lines (195 loc) · 6.58 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
<?php
session_start();
if(isset($_POST['username']) && isset($_POST['password'])){
include "db.php";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = "SELECT * FROM login WHERE username = '".$_POST['username']."' AND password = '".$_POST['password']."' ";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
// output data of each row
while($row = $result->fetch_assoc()) {
$_SESSION['userid'] = $row['srno'];
$_SESSION['work'] = $_POST['type'];
echo "success";
}
}
exit;
}
// Unset all of the session variables.
$_SESSION = array();
// If it's desired to kill the session, also delete the session cookie.
// Note: This will destroy the session, and not just the session data!
if (ini_get("session.use_cookies")) {
$params = session_get_cookie_params();
setcookie(session_name(), '', time() - 42000,
$params["path"], $params["domain"],
$params["secure"], $params["httponly"]
);
}
// Finally, destroy the session.
session_destroy();
?>
<html>
<head>
<title>SmartBills</title>
<link href='css/opensans.css' rel='stylesheet' type='text/css'>
<link rel="stylesheet" href="css/font-awesome.min.css">
<link rel="stylesheet" href="css/bootstrap.min.css">
<script src="js/jquery.min.js"></script>
<script src="js/bootstrap.min.js"></script>
<script>
function submit(){
var username = document.getElementById("username").value;
var password = document.getElementById("password").value;
var type = document.getElementById("type").value;
var data = {
username : username,
password : password,
type : type
};
$.post( "index.php", data)
.done(function( data1 ) {
if(data1.trim() == 'success'){
location.href = 'home.php';
}else{
$('#myModal').modal('show');
}
});
}
</script>
<style>
body{
font-family: 'Open Sans';
}
.login-page {
width: 360px;
padding: 8% 0 0;
margin: auto;
}
.form {
position: relative;
z-index: 1;
background: #FFFFFF;
max-width: 360px;
margin: 0 auto 100px;
padding: 45px;
text-align: center;
box-shadow: 0 0 20px 0 rgba(0, 0, 0, 0.2), 0 5px 5px 0 rgba(0, 0, 0, 0.24);
}
.form input {
outline: 0;
background: #f2f2f2;
width: 100%;
border: 0;
margin: 0 0 15px;
padding: 15px;
box-sizing: border-box;
font-size: 14px;
}
.form button {
text-transform: uppercase;
outline: 0;
background: #5BC0DE;
width: 100%;
border: 0;
padding: 15px;
color: #ffffff;
font-weight: bold;
font-size: 14px;
cursor: pointer;
}
.form button:hover,.form button:active,.form button:focus {
background: #51ACC7;
}
.form .message {
margin: 15px 0 0;
color: #b3b3b3;
font-size: 12px;
}
.form .message a {
color: #4CAF50;
text-decoration: none;
}
.form .register-form {
display: none;
}
.container {
position: relative;
z-index: 1;
max-width: 300px;
margin: 0 auto;
}
.container:before, .container:after {
content: "";
display: block;
clear: both;
}
.container .info {
margin: 50px auto;
text-align: center;
}
.container .info h1 {
margin: 0 0 15px;
padding: 0;
font-size: 36px;
font-weight: 300;
color: #1a1a1a;
}
.container .info span {
color: #4d4d4d;
font-size: 12px;
}
.container .info span a {
color: #000000;
text-decoration: none;
}
.container .info span .fa {
color: #EF3B3A;
}
body {
background : url('img/bg.jpg');
}
</style>
</head>
<body>
<div class="login-page" id="wrap">
<div class="form">
<h2>SmartBills</h2>
<div class="login-form">
<input type="text" placeholder="username" id="username"/>
<input type="password" placeholder="password" id="password"/>
<select id="type" style="margin-top: 5px; margin-bottom: 20px" class="form-control">
<option value="precision">Precision</option>
<option value="fine">Fine</option>
</select>
<button type="button" onclick="submit()">login <i class="fa fa-sign-in" aria-hidden="true"></i></button>
</div>
</div>
<div id="push"></div>
</div>
<?php include "footer.php" ?>
<!-- Modal -->
<div id="myModal" class="modal fade" role="dialog">
<div class="modal-dialog modal-sm">
<!-- Modal content-->
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title" style="color:red">Login Failed!</h4>
</div>
<div class="modal-body">
<p>Username or Password Incorrect.</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-sm" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
</body>
</html>