Webbserverprogrammering 1

Show sourcecode

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

webbsrvprg/slutprojekt/

admin.php
confirmSignIn.php
createadmin.php
logIn.php
signIn.php
start.php
startsida.php
style.css
tables.php
update.php

confirmSignIn.php

47 lines UTF-8 Windows (CRLF)
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Jass</title>
</head>
<body>
  <?php
    
/** @var PDO $dbconn */
    
include ('../dbconnection.php');

    echo 
"<br>Name: " $_COOKIE["newname"];
    echo 
"<br>Pwd: " $_COOKIE["newpwd"];
    echo 
"<br>Name: " $_COOKIE["newmail"];
    echo 
"<br>Name: " $_COOKIE["mailId"];

    if (isset(
$_GET["mailId"]) && isset($_COOKIE["newname"]) && isset($_COOKIE["newmail"]) && isset($_COOKIE["newpwd"]) && isset($_COOKIE["mailId"])) {
      if (
$_GET["mailId"] == $_COOKIE["mailId"]) {
        
// Om namnet inte är använt, skapa kontot och logga in
        
$name $_COOKIE["newname"];
        
$pwd $_COOKIE["newpwd"];
        
$mail $_COOKIE["newmail"];

        try {
          
$sql "INSERT INTO JassPlayers (username, password, mail, type)
          VALUES (?, ?, ?, ?)"
;
          
$stmt $dbconn->prepare($sql);

          
$data = array($name$pwd$mail"user");
          
$stmt->execute($data);

          
header("location: logIn.php?username=$name&password=$pwd");

          echo 
"Kontot är skapat!";
        } catch (
PDOException $e) {
          echo 
$sql "<br>" $e->getMessage();
        }
      } else {
        echo 
"g";
      }
    } else {
      echo 
"h";
    }
  
?>
</body>
</html>