Commit 3ed4dfd 1 parent 685ba96 commit 3ed4dfd Copy full SHA for 3ed4dfd
File tree 1 file changed +6
-19
lines changed
1 file changed +6
-19
lines changed Original file line number Diff line number Diff line change 1
1
<?php
2
2
$ auth_required = true ;
3
3
require_once ("../config.php " );
4
-
5
- function get_candidates () {
6
- global $ DB ;
7
- $ query = mysqli_prepare ($ DB , "SELECT id, name FROM `candidates` " );
8
- mysqli_stmt_execute ($ query );
9
- mysqli_stmt_bind_result ($ query , $ id , $ name );
10
- mysqli_stmt_store_result ($ query );
11
- $ results = array ();
12
- while (mysqli_stmt_fetch ($ query )){
13
- $ results [$ id ] = $ name ;
14
- }
15
- return $ results ;
16
- }
17
-
4
+
18
5
$ htmlOutput = "" ;
19
-
6
+
20
7
$ htmlOutput .= "<h1>Candidates</h1> " ;
21
8
$ candidates = get_candidates ();
22
9
if ( count ($ candidates ) != 0 ) {
@@ -29,15 +16,15 @@ function get_candidates() {
29
16
else {
30
17
$ htmlOutput .= "None<br> " ;
31
18
}
32
-
19
+
33
20
$ htmlOutput .= "<br><hr><br> " ;
34
21
$ htmlOutput .= "<h3>Add a candidate</h3> " ;
35
22
$ htmlOutput .= "<form action='add_candidate.php' method='post' autocomplete='off'>
36
23
Name <input type='text' name='candidate_name' required><br>
37
24
<input class='btn' type='submit' value='Add Candidate'> " ;
38
-
25
+
39
26
$ htmlOutput .= "<script>document.body.onload=function(){document.getElementsByName('candidate_name')[0].focus()}</script> " ;
40
-
27
+
41
28
$ htmlOutput .= "<br><br><br><br><a class='btn btn-green' href=' " .$ base_url ."admin/'>Go to Allow Voting</a> " ;
42
-
29
+
43
30
include ("../template.php " );
You can’t perform that action at this time.
0 commit comments