-
Notifications
You must be signed in to change notification settings - Fork 0
/
vote.php
executable file
·46 lines (44 loc) · 1.02 KB
/
vote.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
<?php
include("connect.php");
$title = "AArt - Your home for ASCII Art";
include("header.html");
include("sidebar.php");
?>
<div class="flakes-content">
<div class="view-wrap">
<h1>Voting!</h1>
</div>
<?php
if(isset($_GET['id']) and isset($_GET['type'])){
$id = mysqli_real_escape_string($conn, $_GET['id']);
$type = mysqli_real_escape_string($conn, $_GET['type']);
if($type === "up"){
$sql = "UPDATE art SET karma=karma+1 where id='$id';";
} elseif($type === "down"){
$sql = "UPDATE art SET karma=karma-1 where id='$id';";
}
mysqli_query($conn, $sql);
$sql = "SELECT karma, title from art where id='$id'";
$result = mysqli_query($conn, $sql);
$row = $result->fetch_assoc();
?>
<div class="grid-1">
<div class="span-1">
<h2><?php echo($row['title']);?> now has <?php echo($row['karma']);?> karma</h2>
</div>
</div>
<?php
} else {
?>
<div class="grid-1">
<div class="span-1">
<h2>What are you doing here?</h2>
</div>
</div>
<?php
}
?>
</div>
<?php
include("footer.html");
?>