-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathindex.php
102 lines (89 loc) · 2.64 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
<?php
session_start();
include 'conn.php';
?>
<!DOCTYPE html>
<html>
<head>
<title>EVoting - Login</title>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css">
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
body {font-family: Arial, Helvetica, sans-serif;}
form {border: 3px solid #f1f1f1;}
input[type=text], input[type=password] {
width: 100%;
padding: 12px 20px;
margin: 8px 0;
display: inline-block;
border: 1px solid #ccc;
box-sizing: border-box;
}
#button {
background-color: #4CAF50;
color: white;
padding: 14px 20px;
margin: 8px 0;
border: none;
cursor: pointer;
width: 100%;
}
#button:hover {
opacity: 0.8;
}
span.psw {
float: right;
padding-top: 16px;
}
/* Change styles for span and cancel button on extra small screens */
@media screen and (max-width: 300px) {
span.psw {
display: block;
float: none;
}
}
</style>
</head>
<body>
<h2 class="text-center my-3">Voter's Login</h2>
<div class="container">
<?php
if(isset($_POST['login']))
{
$voter_id = $_POST['voter_id'];
$password = $_POST['password'];
$sql = "SELECT * FROM voters WHERE voters_id='$voter_id' AND password='$password'";
$q = mysqli_query($con, $sql);
if(mysqli_num_rows($q) > 0)
{
$get_voters_details = mysqli_fetch_array($q);
$get_voters_name = $get_voters_details['name'];
$_SESSION['voter_id'] = $voter_id;
$_SESSION['voter_name'] = $get_voters_name;
header('Location:voting.php');
}
else
{
echo '<div class="alert alert-warning alert-dismissible fade show" role="alert"><strong>Login Failed</strong><button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button></div>';
}
}
?>
<div class="row">
<div class="col-md-3"></div>
<div class="col-md-6">
<form action="" method="post">
<label for="voter_id"><b>Voting Id</b></label>
<input type="text" placeholder="Enter Username" name="voter_id" id="voter_id" autofocus required>
<label for="password"><b>Password</b></label>
<input type="password" placeholder="Enter Password" name="password" id="password" required>
<button type="submit" id="button" name="login">Login</button>
</form>
</div>
<div class="col-md-3"></div>
</div>
</div>
<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.0/dist/umd/popper.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/js/bootstrap.min.js"></script>
</body>
</html>