-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathauthentication.php
161 lines (121 loc) · 5.84 KB
/
authentication.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
<title>Bootstrap 101 Template</title>
<!-- Bootstrap -->
<link href="css/bootstrap.min.css" rel="stylesheet">
<link href='http://fonts.googleapis.com/css?family=Ubuntu' rel='stylesheet' type='text/css'>
<link href='http://fonts.googleapis.com/css?family=Raleway' rel='stylesheet' type='text/css'>
<link href='http://fonts.googleapis.com/css?family=Oswald' rel='stylesheet' type='text/css'>
<link href='http://fonts.googleapis.com/css?family=Roboto+Condensed' rel='stylesheet' type='text/css'>
<style>
.headerFont{
font-family: 'Ubuntu', sans-serif;
font-size: 24px;
}
.subFont{
font-family: 'Raleway', sans-serif;
font-size: 14px;
}
.specialHead{
font-family: 'Oswald', sans-serif;
}
.normalFont{
font-family: 'Roboto Condensed', sans-serif;
}
</style>
<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
</head>
<body>
<div class="container">
<nav class="navbar navbar-default navbar-fixed-top navbar-inverse
" role="navigation">
<div class="container">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#example-nav-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<div class="navbar-header">
<a href="cpanel.php" class="navbar-brand headerFont text-lg"><strong>MATDAAN</strong></a>
</div>
<div class="collapse navbar-collapse" id="example-nav-collapse">
<ul class="nav navbar-nav">
<!--
<li><a href="#featuresTab"><span class="subFont"><strong>Features</strong></span></a></li>
<li><a href="#feedbackTab"><span class="subFont"><strong>Feedback</strong></span></a></li>
<li><a href="#"><span class="subFont"><strong>About</strong></span></a></li>
-->
</ul>
<button type="submit" class="btn btn-success navbar-right navbar-btn"><span class="normalFont"><strong>Admin Panel</strong></span></button>
</div>
</div> <!-- end of container -->
</nav>
<div class="container" style="padding-top:150px;">
<div class="row">
<div class="col-sm-4"></div>
<div class="col-sm-4 text-center" style="border:2px solid gray;padding:50px;">
<?php
// Credentials
$hostname= "localhost";
$username= "root";
$password= "";
$database= "db_evoting";
// UserInput Test
function test_input($data) {
$data = trim($data);
$data = stripslashes($data);
$data = htmlspecialchars($data);
return $data;
}
if(empty($_POST['adminUserName']) || empty($_POST['adminPassword']))
{
$error= "UserName or Password is Recquired.";
}
else
{
$admin_username= test_input($_POST['adminUserName']);
$admin_password= test_input($_POST['adminPassword']);
//Establish Connection
$conn= mysqli_connect($hostname, $username, $password, $database);
//Check
if(!$conn)
{
die("Connection Failed : ".mysqli_connect_error());
}
$sql= "SELECT * FROM db_evoting.tbl_admin WHERE admin_username='".$admin_username."' AND admin_password='".$admin_password."'";
$query= mysqli_query($conn, $sql);
if(mysqli_num_rows($query)==1)
{
header("location:cpanel.php");
}
else
{
$error="Sorry !! Authentication Failed";
echo "<p class='alert alert-danger'><strong>$error</strong></p>";
echo "<p class='normalFont text-primary'><strong>Your Combination of UserName and Password is In-correct. Better, You contact to the developer of system.</strong> </p>";
echo "<br><a href='admin.html' class='btn btn-primary'><span class='glyphicon glyphicon-refresh'></span> <strong>Try Again</strong></a>";
}
mysqli_close($conn);
}
?>
</div>
<div class="col-sm-4"></div>
</div>
</div>
</div>
<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<!-- Include all compiled plugins (below), or include individual files as needed -->
<script src="js/bootstrap.min.js"></script>
</body>
</html>