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

createaccount.php

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

if (isset(
$_POST['name']) && ($_POST['name']!=NULL) && isset($_POST['pass']) && ($_POST['pass']!=NULL) && isset($_POST['email'])){
    
$useristaken false;
    
$sql "SELECT * FROM rpsusers";
    
$stmt $dbconn -> prepare($sql);
    
$stmt -> execute();
    while(
$res $stmt->fetch(PDO::FETCH_ASSOC)){
        if(
$res['username'] == $_POST['name']){
            
$useristaken true;
        }
    }
    if(
$useristaken == false){
        if (
filter_var($_POST['email'], FILTER_VALIDATE_EMAIL)) {
            
//ADD eMAIL!!!!!
            
$sql "INSERT INTO pendingusers (username, pass, email, emailkey, regtime) VALUES (?,?,?,?,?)";
            
$stmt $dbconn -> prepare($sql);
            
$emailkey rand(100000,1000000);
            
$data = [$_POST['name'], $_POST['pass'], $_POST['email'], $emailkeytime()];
            
$stmt -> execute($data);
            

            
$name $_POST['name'];

            
mail($_POST['email'], "account email verification""https://labb.vgy.se/~leown/webbsrvprg/projects/verification.php?key=$emailkey&username=$name"'verification email');
            echo 
"check email inbox";
        }    
        else{ 
            echo 
"Invalid email format";
        }
    }
    else{
        echo 
"username already taken";
    }
}


?>


<html>
    <h1>Skapa konto</h1>
    <form action="createaccount.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>
                    E-mail:
                </td>
                <td>
                    <input type="text" name="email">
                </td>
            </tr>
            <tr>
                <td>
                <input type="submit" >
                </td>
            </tr>
        </table>
    </form>
</html>