82 lines
3.3 KiB
PHP
82 lines
3.3 KiB
PHP
<?php
|
|
if (isset($_SESSION["user"]))
|
|
header("Location: /");
|
|
|
|
if (isset($_POST["register"])) {
|
|
$form = (object) [
|
|
"username" => htmlspecialchars($_POST["username"]),
|
|
"password" => htmlspecialchars($_POST["password"]),
|
|
"password_confirm" => htmlspecialchars($_POST["password_2"]),
|
|
];
|
|
|
|
$register = new Register($form->username, $form->password, $conn);
|
|
|
|
$register->checkUsername();
|
|
$register->checkPassword($form->password_confirm);
|
|
|
|
if ($register->error == NULL) {
|
|
$register->insertUser();
|
|
header("Location: /");
|
|
}
|
|
}
|
|
?>
|
|
<html>
|
|
<head>
|
|
<title><?= $website->title; ?>: <?= $website->slogan; ?></title>
|
|
<link rel="stylesheet" href="styles/main.css">
|
|
</head>
|
|
|
|
<body>
|
|
<table class="container" align="center">
|
|
<tbody>
|
|
<?php require("includes/header.php"); ?>
|
|
|
|
<tr>
|
|
<td>
|
|
<table class="form-box big-box login" align="center" border="1">
|
|
<tbody>
|
|
<tr>
|
|
<th align="left" colspan="2">Duck register</th>
|
|
</tr>
|
|
|
|
<form action="/temp_register" method="POST">
|
|
<tr>
|
|
<td class="label-box" align="right">username: </td>
|
|
<td><input type="text" name="username" /></td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td class="label-box" align="right">password: </td>
|
|
<td><input type="password" name="password" /></td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td class="label-box" align="right">confirm password: </td>
|
|
<td><input type="password" name="password_2" /></td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td class="right-hidden-border"></td>
|
|
<td class="small-text">
|
|
<?php
|
|
if (isset($_POST["register"]) && isset($register))
|
|
if ($register->error != NULL) echo "<font style=\"color: #831f1f\">$register->error</font> <br>";
|
|
?>
|
|
</td>
|
|
</tr>
|
|
|
|
<tr class="top-hidden-border">
|
|
<td class="right-hidden-border"></td>
|
|
<td class="submit-pad"><input type="submit" name="register" value="register" /></td>
|
|
</tr>
|
|
</form>
|
|
</tbody>
|
|
</table>
|
|
</td>
|
|
</tr>
|
|
|
|
<?php require("includes/footer.php"); ?>
|
|
</tbody>
|
|
</table>
|
|
</body>
|
|
</html>
|