View sourcecode

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

signup.php

59 lines UTF-8 Unix (LF)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
<?php
session_start
();

require_once 
"functions/database.php";

if(isset(
$_POST["submit"])){
    
$db->query("INSERT INTO `accountData`(`username`, `password`, `mail`) VALUES (:username, :password, :mail)"
    array(
        
"username"=>$_POST["username"],
        
"password"=>hash("sha256"$_POST["password"], false),
        
"mail"=>$_POST["mail"]
    ));
    
$userID $db->getLastId();

    
$db->query("INSERT INTO `transaction`(`userID`, `value`) VALUES (:userID, 1000)", array("userID"=>$userID));
    
$_SESSION["userID"] = $userID;
}

if(isset(
$_SESSION["userID"])){
    
header("location: account.php");
}
?>

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Olivers bank</title>
    <link rel="stylesheet" href="style.css">
</head>
<body>
    <form action="" method="post" enctype="multipart/form-data" autocomplete="off">
        <h2>Skapa konto</h2>
        <label>Användarnamn</label>
<br>

        <input type="text" name="username">
<br>
<br>
        <label>Mail</label>
<br>

        <input type="mail" name="mail">
<br>
<br>

        <label>Lösenord</label>
<br>

        <input type="password" name="password">

        <button type="submit" name="submit">Skapa konto</button>

        <p class="error"><?php echo @$user->error ?></p>
        <p class="success"><?php echo @$user->success ?></p>
    </form>
    <a href="index.php">Logga in istället</a>
</body>