Webbserverprogrammering 1

Show sourcecode

The following files exists in this folder. Click to view.

webbsrvprg/projects/

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

delete-quiz.php

105 lines ASCII Windows (CRLF)
<?php require('logincheck.php'); 
if(
$_SESSION['isadmin']!=1){
    
header("Location:quizhub.php");
    die;
}
?>

<html>
    <h1>radera quiz</h1>
    <?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>');
        }
        
////////////////////////////////////////////////////////
        
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)){
                
$selectedQuizID $res['listid'];
                echo 
"quiz deleted";
            }
            
///////////////////////////////////////////////////////
            
$selectedQuestionsID = [];
            
$sql "SELECT * FROM qquestions WHERE qlkey='$selectedQuizID'";
            
$stmt $dbconn -> prepare($sql);
            
$stmt -> execute();
            while(
$res $stmt->fetch(PDO::FETCH_ASSOC)){
                
array_push($selectedQuestionsID$res['questionid']);
            }
            
//////////////////////////////////////////////////////////
            
foreach($selectedQuestionsID as $key){
                
/*$sql = "SELECT * FROM qquestions WHERE questionid='$key'";
                $stmt = $dbconn -> prepare($sql);
                $stmt -> execute();
                while($res = $stmt->fetch(PDO::FETCH_ASSOC)){
                    $sql = "DELETE FROM qquestions WHERE questionid='$key'";
                    $stmt = $dbconn -> prepare($sql);
                    $stmt -> execute();
                }
                $sql = "SELECT * FROM qanswers WHERE qqkey='$key'";
                $stmt = $dbconn -> prepare($sql);
                $stmt -> execute();
                while($res = $stmt->fetch(PDO::FETCH_ASSOC)){
                    $sql = "DELETE FROM qanswers WHERE qqkey='$key'";
                    $stmt = $dbconn -> prepare($sql);
                    $stmt -> execute();
                }*/

                
$sql "SELECT * FROM qquestions WHERE questionid='$key'";
                
$stmt $dbconn -> prepare($sql);
                
$stmt -> execute();
                while(
$res $stmt->fetch(PDO::FETCH_ASSOC)){
                    
$sql "DELETE FROM qquestions WHERE questionid='$key'";
                    
$stmt $dbconn -> prepare($sql);
                    
$stmt -> execute();
                }
                
$sql "SELECT * FROM questionanswers WHERE qqkey='$key'";
                
$stmt $dbconn -> prepare($sql);
                
$stmt -> execute();
                while(
$res $stmt->fetch(PDO::FETCH_ASSOC)){
                    
$sql "DELETE FROM questionanswers WHERE qqkey='$key'";
                    
$stmt $dbconn -> prepare($sql);
                    
$stmt -> execute();
                }
                    
                
$sql "SELECT EXISTS(SELECT * FROM qresults WHERE qkey='$key')";
                
$stmt $dbconn -> prepare($sql);
                
$stmt -> execute();
                while(
$res $stmt->fetch(PDO::FETCH_ASSOC)){
                    
$sql "DELETE FROM qresults WHERE qkey='$key'";
                    
$stmt $dbconn -> prepare($sql);
                    
$stmt -> execute();
                }

                
$sql "SELECT EXISTS(SELECT * FROM quserresults WHERE quizkey='$key')";
                
$stmt $dbconn -> prepare($sql);
                
$stmt -> execute();
                while(
$res $stmt->fetch(PDO::FETCH_ASSOC)){
                    
$sql "DELETE FROM quserresults WHERE quizkey='$key'";
                    
$stmt $dbconn -> prepare($sql);
                    
$stmt -> execute();
                }
            }
                
$sql "SELECT EXISTS(SELECT * FROM qlist WHERE listid='$selectedQuizID')";
                
$stmt $dbconn -> prepare($sql);
                
$stmt -> execute();
                while(
$res $stmt->fetch(PDO::FETCH_ASSOC)){
                    
$sql "DELETE FROM qlist WHERE listid='$selectedQuizID'";
                    
$stmt $dbconn -> prepare($sql);
                    
$stmt -> execute();
                }
            
            
$_GET=[];
        }



    
?>
</html>