-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
128 lines (108 loc) · 3.6 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
<?php session_start() ?>
<link rel="stylesheet" type="text/css" href="admin/css/style.css" />
<?php include('dbcon.php');
include('header.php');
?>
</head>
<body>
<div class="navbar navbar-fixed-top">
<div class="navbar-inner">
<div class="container">
<a class="brand">
<img src="admin/images/logo.jpg" width="60" height="60">
</a>
<a class="brand">
<h2>ONLINE VOTING SYSTEM</h2>
<div class="chmsc_nav"><font size="4" color="white">CU</font></div>
</a>
<?php include('head.php'); ?>
</div>
</div>
</div>
<div class="wrapper_admin">
</br>
</br>
</br>
<div id="element" class="hero-body-index">
<p><font color="white"><h2>Voter Login</h2></font></p>
<form method="POST" >
<table>
<tr><td><font color="white">UserName:</font> </td><td><input type="text" name="UserName" class="UserName_hover"></td></tr>
<tr><td>...<td></tr>
<tr><td><font color="white">Password:</font> </td><td><input type="Password" name="Password" class="Password_hover"></td></tr>
<tr><td>...<td></tr>
<tr><td></td><td> <button class="btn btn-primary" name="Login"><i class="icon-ok icon-large"></i> Login</button>
</td></tr>
<tr><td>
</td><tr>
</form>
</table>
</br>
<div class="error">
<?php
if (isset($_POST['Login'])){
$UserName=$_POST['UserName'];
$Password=$_POST['Password'];
$login_query=mysqli_query($conn,"select * from voters where Username='$UserName' and Password='$Password' and Status='Unvoted' and Year='1st year'") or die(mysqli_error());
$login_query3=mysqli_query($conn,"select * from voters where Username='$UserName' and Password='$Password' and Status='Unvoted' and Year='2nd year'") or die(mysqli_error());
$login_query4=mysqli_query($conn,"select * from voters where Username='$UserName' and Password='$Password' and Status='Unvoted' and Year='3rd year'") or die(mysqli_error());
$login_query5=mysqli_query($conn,"select * from voters where Username='$UserName' and Password='$Password' and Status='Unvoted' and Year='4th year'") or die(mysqli_error());
//
$login_query1=mysqli_query($conn,"select * from voters where Username='$UserName' and Password='$Password' and Status='Voted'");
$login_query2=mysqli_query($conn,"select * from voters where Username='$UserName' and Password='$Password' and Status='Voted'");
$count=mysqli_num_rows($login_query);
$count1=mysqli_num_rows($login_query1);
$count3=mysqli_num_rows($login_query3);
$count4=mysqli_num_rows($login_query4);
$count5=mysqli_num_rows($login_query5);
$row=mysqli_fetch_array($login_query);
$row3=mysqli_fetch_array($login_query3);
$row4=mysqli_fetch_array($login_query4);
$row5=mysqli_fetch_array($login_query5);
// $id=$row['VoterID'];
?>
<?php
if($count == 1){
$_SESSION['id']=$row['VoterID'];
_redirect('voting.php');
}
if($count3 == 1){
$_SESSION['id']=$row3['VoterID'];
_redirect('voting2.php');
}
if($count4 == 1){
$_SESSION['id']=$row4['VoterID'];
_redirect('voting3.php');
}
if($count5 == 1){
$_SESSION['id']=$row5['VoterID'];
_redirect('voting4.php');
}
if($count == 1 || $count1 == 1 || $count3 == 1 || $count4 == 1 || $count5 == 1){ ?>
<div class="alert alert-error">
<button class="close" data-dismiss="alert">�</button>
You Can Only Vote Once
</div>
<?php
}else{ ?>
<div class="alert alert-error">
<button class="close" data-dismiss="alert">�</button>
Please check your username and password
</div>
<?php
}
?>
<?php
}
?>
</div>
</div>
</br>
</br>
</br>
</br>
</br>
<?php include('footer.php')?>
</div>
</body>
</html>