-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathanswer.php
More file actions
46 lines (32 loc) · 1.07 KB
/
Copy pathanswer.php
File metadata and controls
46 lines (32 loc) · 1.07 KB
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
session_start();
require_once("database.php");
if (!$_SESSION["valid_user"])
{
Header("Location: loginform.php");
}
$level = $_SESSION["level"];
$answer = $_GET["answer"];
$sql = "INSERT INTO logs (user,val,level) VALUES ('" . mysql_real_escape_string($_SESSION["valid_user"]) . "','" . mysql_real_escape_string($answer) . "','". $level . "')";
$ref = mysql_query($sql);
$sql = "SELECT * FROM levels WHERE name = '" . mysql_real_escape_string($level) . "'" ;
$ref = mysql_query($sql);
$row = mysql_fetch_assoc($ref);
$ans = $row['answer'];
if(!($ans))
{
$content .= "you are trying to answer a question that has not yet been decided";
}
else if($answer == $row['answer'])
{
$level++;
$_SESSION["level"] = $level;
$content = "Answer is right. <a href = \"index.php\">Next Level</a>";
$sql = "UPDATE users SET level = '" . $level . "' WHERE name = '" . $_SESSION["name"] ."'";
$ref = mysql_query($sql);
$content = $content;
}
else
$content = "Wrong answer. <a href = \"index.php\">Try again</a>";
require_once("theme/theme.php");
?>