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

create-account.php

58 lines UTF-8 Windows (CRLF)
<?php
require("../incl/dbconnection.php");

if (isset(
$_POST['name']) && ($_POST['name']!=NULL) && isset($_POST['pass']) && ($_POST['pass']!=NULL)){
    
$useristaken false;
    
$sql "SELECT * FROM qusers";
    
$stmt $dbconn -> prepare($sql);
    
$stmt -> execute();
    while(
$res $stmt->fetch(PDO::FETCH_ASSOC)){
        if(
$res['name'] == $_POST['name']){
            
$useristaken true;
        }
    }
    if(
$useristaken == false){
        
$sql "INSERT INTO qusers (username, pass, isadmin) VALUES (?,?, 0)";
        
$stmt $dbconn -> prepare($sql);
        
$data = [$_POST['name'], $_POST['pass']];
        
$stmt -> execute($data);
        
header('Location:login.php');
    }
    else{
        echo 
"username already taken";
    }
}


?>


<html>
    <h1>Skapa konto</h1>

    <form action="create-account.php" method="POST">
        <table>
            <tr>
                <td>
                    Användarnamn:
                </td>
                <td>
                    <input type="text" name="name">
                </td>
            </tr>
            <tr>
                <td>
                    Lösenord:
                </td>
                <td>
                    <input type="text" name="pass">
                </td>
            </tr>
            <tr>
                <td>
                <input type="submit" >
                </td>
            </tr>
        </table>
    </form>
</html>