-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhomepage.php
55 lines (47 loc) · 1.32 KB
/
homepage.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
<!DOCTYPE html>
<html>
<head>
<title>Voting page</title>
<link rel="stylesheet" type="text/css" href="style1.css">
</head>
<body>
<h1 style="text-align: center; font-family: 'Do Hyeon'; color:red; margin-top: 2%; font-size: 50px;color: #ffffff;">Online Voting</h1>
<form action="" method="POST">
<div class="container">
<div class="box1">
<div class="hea_box1">Avengers</div>
<div class="image">
<img src="Marvel.jpg" alt="Error">
</div>
<button class="btn" name="vote" value="M">VOTE</button>
</div>
<div class="box2">
<div class="hea_box2">Justice league</div>
<div class="image">
<img src="dc.jpg" alt="Error">
</div>
<button class="btn" name="vote" value="D">VOTE</button>
</div>
</div>
</form>
</body>
</html>
<?php
$connection = mysqli_connect("localhost","root","");
$db = mysqli_select_db($connection,"votedb");
if(isset($_POST['vote']))
{
$vote = $_POST['vote'];
$query = "INSERT INTO `voterlist` (`vote`) VALUES ('$vote')" ;
$query_run = mysqli_query($connection,$query);
if($query_run)
{
echo '<script type ="text/javascript"> alert("Vote Added") </script>';
header('location: success.php');
}
else
{
echo '<script type ="text/javascript"> alert("Vote failed!") </script>';
}
}
?>