Show sourcecode
The following files exists in this folder. Click to view.
bacon-egg-pizza.php
cquiz.php
create-account.php
create-account111.php
create-quiz.php
create-quiz2.php
createaccount.php
delete-quiz.php
drop-rps-tables.php
legacy-code-rps.php
legacy-index.php
login.php
logincheck.php
newpassword-verify.php
newpassword.php
potential-code.txt
quiz-db-init.php
quizhub.php
quizhub2.php
results.php
rpsaccount-ajax-user-search.php
rpsaccount.php
rpsbetting-ajax-match-finder.php
rpsbetting.php
rpsbettingleaderboard.php
rpschangepassword.php
rpschangepassword.txt
rpsgame-ajax.php
rpsgame.php
rpsgameresults.php
rpshostnewgame.php
rpshub.php
rpsleaderboard.php
rpslib.php
rpslogin.php
rpsmaininclude.php
rpsproject/
rpsusersearch.php
table-init.php
verification.php
quizhub.php
150 lines UTF-8 Windows (CRLF)
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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
<?php require('logincheck.php'); ?>
<html>
<h1>Quizhub</h1>
<h3>välkommen <?php echo $_SESSION['user']; ?></h3>
välj quiz
<br>
<?php
$sql = "SELECT * FROM qlist";
$stmt = $dbconn->prepare($sql);
$stmt->execute();
while($res = $stmt->fetch(PDO::FETCH_ASSOC)){
$quizName = $res['qlname'];
echo('<form action="" method="GET"><button type="submit" name="quiz" value="'.$quizName.'">'.$quizName.'</button>');
}
?>
</form>
<?php
if(isset($_GET['quiz'])){
$selectedQuiz = $_GET['quiz'];
$sql = "SELECT * FROM qlist WHERE qlname='$selectedQuiz'";
$stmt = $dbconn->prepare($sql);
$stmt->execute();
while($res = $stmt->fetch(PDO::FETCH_ASSOC)){
$quizID = $res['listid'];
}
echo $selectedQuiz.'<br><br><form action="" method="POST">';
$sql = "SELECT * FROM qquestions WHERE qlkey='$quizID'";
$stmt = $dbconn->prepare($sql);
$stmt->execute();
$currentQuestionsID=[];
$currentQuestions=[];
while($res = $stmt->fetch(PDO::FETCH_ASSOC)){
$questionID = $res['questionid'];
array_push($currentQuestionsID, $questionID);
$questionName = $res['qqname'];
array_push($currentQuestions, $questionName);
}
$correctAnswers=[];
GLOBAL $correctAnswers;
$qqCounter=0;
foreach($currentQuestionsID as $qID){
//$qID = $questionID;
$cqname = $currentQuestions[$qqCounter];
GLOBAL $cqname;
$qqCounter+=1;
echo $cqname;
$sql = "SELECT * FROM qanswers WHERE qqkey='$qID'";
$stmt = $dbconn->prepare($sql);
$stmt->execute();
$currentAnswers=[];
$currentAnswersID=[];
while($res = $stmt->fetch(PDO::FETCH_ASSOC)){
$ans1 = $res['ans1'];
$ans2 = $res['ans2'];
$ans3 = $res['ans3'];
$cans = $res['correct'];
$aID = $res['id'];
array_push($currentAnswers, $ans1);
array_push($currentAnswers, $ans2);
array_push($currentAnswers, $ans3);
array_push($correctAnswers, $cans);
array_push($currentAnswersID, $aID);
}
foreach($currentAnswers as $ans){
echo('<input type="radio" name="'.$cqname.'" value="'.$ans.'">'.$ans.'</input>');
}
echo "<br>";
}
echo '<input type="submit"></form>';
if(isset($_POST[$cqname])){
$arrayCounter = 0;
$totalscore=0;
$resultString = 'Svar<br>';
foreach($currentQuestions as $question){
if(isset($_POST[$question])){
$score = 0;
if($_POST[$question] == $correctAnswers[$arrayCounter]){
$score=1;
$totalscore+=1;
}
$ca = $_POST[$question];
if($ca == $correctAnswers[$arrayCounter]){
$resultString.= $question.': ditt svar: <span style="color:green">'.$ca.'</span><br>';
}
else{
$resultString.= $question.': ditt svar: <span style="color:green">'.$ca.' </span>rätt svar: <span style="color:red">'.$correctAnswers[$arrayCounter].'</span><br>';
}
$cqID = $currentQuestionsID[$arrayCounter];
$uID = $_SESSION['userid'];
$sql = "SELECT EXISTS(SELECT result FROM qresults WHERE qkey='$cqID' AND ukey='$uID')";
$stmt = $dbconn -> prepare($sql);
$stmt -> execute();
while($res = $stmt->fetch(PDO::FETCH_ASSOC)){
$sql = "DELETE FROM qresults WHERE qkey='$cqID' AND ukey='$uID'";
$stmt = $dbconn -> prepare($sql);
$stmt -> execute();
}
$sql = "INSERT INTO qresults (qkey,ukey,result) VALUES (?,?,?)";
$stmt = $dbconn -> prepare($sql);
$data = [$cqID,$uID,$score];
$stmt -> execute($data);
$arrayCounter+=1;
}
}
echo 'ditt resultat: '.$totalscore.'<br>';
echo $resultString;
$sql = "SELECT EXISTS(SELECT * FROM quserresults WHERE quizkey='$quizID' AND userkey='$uID')";
$stmt = $dbconn -> prepare($sql);
$stmt -> execute();
while($res = $stmt->fetch(PDO::FETCH_ASSOC)){
$sql = "DELETE FROM quserresults WHERE quizkey='$quizID' AND userkey='$uID'";
$stmt = $dbconn -> prepare($sql);
$stmt -> execute();
}
$sql = "INSERT INTO quserresults (quizkey,userkey,htmldata,totscore) VALUES ($quizID,$uID,?,?)";
$stmt = $dbconn -> prepare($sql);
$data = [$resultString,$totalscore];
$stmt -> execute($data);
}
}
?>
</html>