-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathcastvote.php
34 lines (29 loc) · 873 Bytes
/
castvote.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
<?php
session_start();
include('dbconnect.php');
$total=$_POST['total'];
$next=$_POST['next'];
if(isset($_POST['pref0'])) {
$pref0=$_POST['pref0'];
$sql="UPDATE nopref SET votes = votes + 1 WHERE post='".$pref0."'";
mysql_query($sql) or die(mysql_error());
}
else {
if(isset($_POST['pref1'])) {
$pref1=$_POST['pref1'];
$sql="UPDATE candidates SET votes1 = votes1 + 1 WHERE id='".$pref1."'";
mysql_query($sql) or die(mysql_error());
}
if(isset($_POST['pref2'])) {
$pref2=$_POST['pref2'];
$sql="UPDATE candidates SET votes2 = votes2 + 1 WHERE id='".$pref2."'";
mysql_query($sql) or die(mysql_error());
}
if(isset($_POST['pref3'])) {
$pref3=$_POST['pref3'];
$sql="UPDATE candidates SET votes3 = votes3 + 1 WHERE id='".$pref3."'";
mysql_query($sql) or die(mysql_error());
}
}
header("Location:".$next.".php");
?>