-
Notifications
You must be signed in to change notification settings - Fork 0
/
solve.php
59 lines (56 loc) · 1.82 KB
/
solve.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
<?php
include 'conn.php';
$username=$_COOKIE['user'];
if (isset($username)) {
if ($username==='admin') {
echo '<nav>
<a href="solve.php">Questions</a>
<a href="leaderboard.php">Leaderboard</a>
<a href="add.php">Add Questions</a>
<a href="viewques.php">View all available questions</a>
<a href="logout.php" style="float: right;">Logout</a>
</nav>';
}else{
echo '<nav>
<a href="solve.php">Questions</a>
<a href="leaderboard.php">Leaderboard</a>
<a href="logout.php" style="float: right;">Logout</a>
</nav>';
}
$user=$conn->query("SELECT * from Users where username='".$username."'");
$info=mysqli_fetch_assoc($user);
echo "Your Points : ".$info['points']."<br>";
$ask="SELECT * FROM results";
$res=$conn->query($ask);
$result=mysqli_fetch_assoc($res);
$query="SELECT * FROM Questions";
$result1=$conn->query($query);
$count=0;
while ($row=mysqli_fetch_assoc($result1)) {
$i=$row['number'];
$ask="SELECT * FROM results WHERE userq='".$username."' AND q='".$i."'";
$res=$conn->query($ask);
$result=mysqli_fetch_assoc($res);
if ($result['status']=='not-answered') {
echo '<form method="POST" action="eval.php">';
echo '<input type="hidden" name="number" value="'.$i.'">';
echo 'Question'.$i.' ';
echo 'Points'.$row['points'].'<br>';
echo ' '.$row['question']."<br>";
echo "Option a)<input type='radio' name='option' value='a'>".$row['a']."<br>";
echo "Option b)<input type='radio' name='option' value='b'>".$row['b']."<br>";
echo "Option c)<input type='radio' name='option' value='c'>".$row['c']."<br>";
echo "Option d)<input type='radio' name='option' value='d'>".$row['d']."<br>";
echo "<input type='submit' value='answer'>";
echo '</form><br><br>';
$count++;
}
}
if ($count===0) {
echo 'You have attempted all available questions';
}
}
else{
header("Location: login.php");
}
?>