forked from RITct/Decipher-2016
-
Notifications
You must be signed in to change notification settings - Fork 1
/
answer.php
131 lines (105 loc) · 2.83 KB
/
answer.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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
<?php
session_start();
if (!isset($_SESSION["fbuid"]))
{$output = "<script>
window.location='index.php';
</script>";
echo $output; }
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Decipher | 2016</title>
<link rel="icon" href="../images/icon.png" type="image/png" sizes="16x16">
<link rel="stylesheet" href="css/style.css" type="text/css">
<link rel="stylesheet" type="text/css" href="css/mobile.css">
<script src="js/mobile.js" type="text/javascript"></script>
<style>
img.ack {
width:500px;
height:300px;
}
.ack {
color:green;
text-align:center;
}
p.ack a {
color:blue;
}
</style>
</head>
<body>
<div id="page">
<div id="header">
<div id="navigation">
<span id="mobile-navigation"> </span>
<a href="index.php" class="logo"><img src="images/logo.png" alt=""></a>
<ul id="menu">
<li class="selected">
<a href="index.php">HOME</a>
</li>
<li>
<a href="leader.php">LEADER BOARD</a>
</li>
<li>
<a href="rules.php">RULES</a>
</li>
<li>
<a href="https://www.facebook.com/decipher.ritu" target="_blank">WATSON</a>
</li>
<?php
session_start();
if (isset($_SESSION["fbuid"]))
echo "<li>
<a href=\"logout.php\">logout</a>
</li>";
?>
</ul>
</div>
</div>
<div id="body" class="home">
<div class="header">
<div>
<!--php code goes here-->
<?php
require_once("database.php");
global $result;
$level = $_SESSION["level"];
$answer = $_GET["answer"];
$name=$_SESSION["name"];
$sql = "INSERT INTO logs (user,val,level) VALUES ('" .$name. "','" . mysqli_real_escape_string($result,$answer) . "','". $level . "')";
$ref = $result->query($sql);
$sql = "SELECT * FROM levels WHERE name = '" . mysqli_real_escape_string($result,$level) . "'" ;
$ref = $result->query($sql);
$row = mysqli_fetch_assoc($ref);
$ans = $row['answer'];
if(!($ans))
{
$content .= "<p class=\"ack\">WAIT FOR MY QUESTION SHERLOCK</p>";
}
else if($answer == $row['answer'])
{
$level++;
$_SESSION["level"] = $level;
if ($level==25)
$content = "<img src=\"imgs/levels/winmob.jpg\"><p class=\"ack\">winner<br>";
else
$content = "<img src=\"imgs/correct/cr".rand(1,7).".jpg\"><p class=\"ack\">RIGHT ANSWER<br> <a href = \"index.php\">Next Level</a></p>";
$sql = "UPDATE users SET level = '" . $level . "' WHERE fbuid = '" . $_SESSION["fbuid"] ."'";
$ref = $result->query($sql);
}
else
{
$content = "<img class=\"ack\" src=\"imgs/wrong/wr".rand(1,6).".jpg\"><p class=\"ack\">Wrong answer<br> <a href = \"index.php\">Try again</a></p>";
}
print $content;
?>
<!--php code goes here-->
</div>
</div>
</div>
</div>
</body>
</html>