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

rpsbetting-ajax-match-finder.php

68 lines UTF-8 Windows (CRLF)
<?php require('rpsmaininclude.php');
session_start();

ob_clean();

    
/*$sKey = $_GET['strInput'];

    $sql = "SELECT * FROM rpsusers WHERE username LIKE '$sKey%' ORDER BY username";
    $stmt = $dbconn->prepare($sql);
    $stmt->execute();

    $outputText = "";
    while($res = $stmt->fetch(PDO::FETCH_ASSOC)){
        $name =  $res['username'];
        $ratio = $res['ratio'];
        if($name!=""){
            $outputText .= '<a href="rpsaccount.php?user='.$name.'">'.$name.'</a>'."&nbsp".$ratio.'<br>';
        }
    }
    echo $outputText;
    */

    
function getMatchesBettingVersionV2($dbconn,$userid) {
        
$sql "SELECT 
            m.matchid, 
            m.player1id, 
            m.player2id, 
            m.isactive,
            u1.userid AS p1id, 
            u1.username AS player1name,
            u2.userid AS p2id, 
            u2.username AS player2name,
            b.matchid AS bmid,
            b.userid AS buid
            FROM matches AS m
            INNER JOIN rpsusers AS u1 ON m.player1id = u1.userid
            INNER JOIN rpsusers AS u2 ON m.player2id = u2.userid
            LEFT JOIN bets AS b on m.matchid = b.matchid"
;
        
        
$stmt $dbconn->prepare($sql);
        
$stmt->execute();
    
        while (
$res $stmt->fetch(PDO::FETCH_ASSOC)) {
            if (
$res['player1id'] != null && $res['player2id'] != null && $res['isactive'] == && $userid!=$res['buid']) {
                echo 
"<div>".
                
"<strong>".$res['player1name']." vs ".$res['player2name']."</strong><br>".
                
'<form action="" method="POST">'.
                
'<input type="radio" name="chosenplayer" value="'.$res['player1id'].'"> '.$res['player1name'].'<br>'.
                
'<input type="radio" name="chosenplayer" value="'.$res['player2id'].'"> '.$res['player2name'].'<br>'.
                
'<input type="number" name="betamount" placeholder="bettingmängd"><br>'.
                
'<input type="hidden" name="matchid" value="'.$res['matchid'].'">'.
                
'<button type="submit">betta</button>'.
                
'</form>'.
                
"</div><hr>";
            }
            else{
                
//echo "no matches";
            
}
        }
    }
    if(isset(
$_GET['userid'])){
        
getMatchesBettingVersionV2($dbconn,$_GET['userid']);
    }
    else{
        echo 
"no userid";
    }
    
?>