-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvoting_page.php
151 lines (123 loc) · 5.44 KB
/
voting_page.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
<?php
//Include authentication
require("process/auth.php");
//Include database connection
require("config/db.php");
//Include class Voting
require("classes/Voting.php");
?>
<!DOCTYPE HTML>
<html lang="en-US">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Voting System</title>
<link rel="stylesheet" href="assets/css/bootstrap.min.css">
<link rel="stylesheet" href="assets/css/style_voter.css">
</head>
<body>
<!-- Header -->
<nav class="navbar navbar-inverse navbar-fixed-top" role="navigation">
<div class="container">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="stud_page.php"><span class="glyphicon glyphicon-home"></span> Voting Sytem</a>
</div>
<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav navbar-right">
<li><a href="stud_page.php"><span class="glyphicon glyphicon-home"></span></a></li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false"><span class="glyphicon glyphicon-user"></span> <span class="caret"></span></a>
<ul class="dropdown-menu">
<li><a href="process/logout.php">Logout</a></li>
</ul>
</li>
</ul>
</div><!-- /.navbar-collapse -->
</div><!-- /.container-fluid -->
</nav>
<!-- End Header -->
<?php
if(isset($_GET['organization'])) {
$org = $_GET['organization'];
}
?>
<?php
$readPos = new Voting();
$rtnReadPos = $readPos->READ_POSITION($org);
?>
<div class="container">
<div class="row">
<?php if($rtnReadPos) { ?>
<div class="col-md-6 col-md-offset-3">
<?php
if(isset($_POST['vote'])) {
$org = trim($_POST['org']);
$pos = trim($_POST['pos']);
$candidate_id = trim($_POST['nominee']);
$voters_id = trim($_POST['voter_id']);
$insertVote = new Voting();
$rtnInsertVote = $insertVote->VOTE_NOMINEE($org, $pos, $candidate_id, $voters_id);
}
?>
<div class="voting-con">
<h4 style="text-align: center;"><?php echo $org; ?> Voting Page</h4><hr />
<?php while($rowPos = $rtnReadPos->fetch_assoc()) { ?>
<form action="<?php $_SERVER['PHP_SELF']; ?>" method="POST" role="form">
<p class="help-block"><b><?php echo $rowPos['pos']; ?></b></p>
<?php
$readNominee = new Voting();
$rtnReadNominee = $readNominee->READ_NOMINEES($org, $rowPos['pos']);
?>
<?php if($rtnReadNominee) { ?>
<div class="form-group">
<select name="nominee" class="form-control">
<option value="">*****Select Nominee*****</option>
<?php while($rowNominee = $rtnReadNominee->fetch_assoc()) { ?>
<option value="<?php echo $rowNominee['id']; ?>"><?php echo $rowNominee['name']; ?></option>
<?php } //End while ?>
</select>
</div>
<?php } //End if ?>
<input type="hidden" name="org" value="<?php echo $org; ?>">
<input type="hidden" name="pos" value="<?php echo $rowPos['pos']; ?>">
<input type="hidden" name="voter_id" value="<?php echo $_SESSION['ID']; ?>">
<?php
$validateVote = new Voting();
$rtnValVote = $validateVote->VALIDATE_VOTE($org, $rowPos['pos'], $_SESSION['ID'])
?>
<button type="submit" name="vote"
<?php if($rtnValVote->num_rows > 0) { ?>
<?php echo "class='btn btn-default disabled'>"; ?>
<?php } else { ?>
<?php echo "class='btn btn-info'>"; ?>
<?php } //End if ?>
Vote
</button>
</form><hr />
<?php } //End while ?>
</div>
</div>
<?php } //End if ?>
</div>
</div>
<!-- Footer -->
<nav class="navbar navbar-inverse navbar-fixed-bottom" role="navigation">
<div class="container">
<div class="navbar-text pull-left">
Copyright 2018 @ Hajjar-Developer
</div>
</div>
</nav>
<!-- End Footer -->
<script src="assets/js/jquery.js"></script>
<script src="assets/js/bootstrap.min.js"></script>
</body>
</html>