Show sourcecode
The following files exists in this folder. Click to view.
createquiz.php
createtable.php
dbconnection.php
index.php
login.php
myquiz.php
registrera.php
results.php
results2.php
takequiz.php
registrera.php
45 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>Document</title>
</head>
<body>
<h1>Skapa ditt Konto</h1>
<form method="post">
<p>Namn</p>
<input type="text" name="namn">
<p>Användarnamn</p>
<input type="text" name="username">
<p>Lösenord</p>
<input type="password" name="password">
<br>
<br>
<button name="create">
Registrera
</button>
</form>
<?php
include('dbconnection.php');
if (isset($_POST['create'])) {
$namn = $_POST['namn'];
$user = $_POST['username'];
$pass = password_hash($_POST['password'], PASSWORD_DEFAULT);
$stmt = $dbconn->prepare("INSERT INTO users (namn, username, password)
VALUES (:namn, :user, :pass)");
$stmt->execute([
':namn' => $namn,
':user' => $user,
':pass' => $pass
]);
header("Location: login.php");
}
$dbconn = null;
?>
</body>
</html>