-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathverification.php
More file actions
47 lines (35 loc) · 838 Bytes
/
verification.php
File metadata and controls
47 lines (35 loc) · 838 Bytes
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
<?php
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "voting";
$conn = mysqli_connect($servername, $username, $password, $dbname);
if (!$conn) {
die("Connection failed: " . mysqli_connect_error());
}
session_start();
$username = $_SESSION['username'];
$query = "SELECT state FROM users WHERE user_id = '$username'";
$result = mysqli_query($conn,$query);
$state = 0;
while($row=mysqli_fetch_assoc($result)){
$state = $row["state"];
break;
}
if($state == 2){
header("Location: /voting/charts.html");
}
elseif($state = 1){
header("Location: /voting/votingballot.html");
}
else{
$query = "UPDATE users SET state=1 WHERE user_id='$username'";
if (mysqli_query($conn,$query)) {
header("Location: /voting/votingballot.html");
}
else {
echo mysqli_error($conn);
}
}
mysqli_close($conn);
?>