84 lines
1.6 KiB
PHP
84 lines
1.6 KiB
PHP
<?php
|
|
//TODO: email / invite registration
|
|
|
|
// if a registration was submitted
|
|
if($_SERVER['REQUEST_METHOD'] == 'POST') {
|
|
|
|
# function to handle failed registrations
|
|
function failed_register($msg) {
|
|
header("Location: /register.php?login_failed=$msg");
|
|
exit();
|
|
}
|
|
|
|
// Assign the form contents to variables
|
|
$username = $_POST['user'] ?? '';
|
|
$password = $_POST['pass'] ?? '';
|
|
|
|
// Check for empty or blank fields
|
|
if ($username == '') failed_register("invalid username");
|
|
if ($password == '') failed_register("invalid password");
|
|
}
|
|
|
|
$title = "~chan - register";
|
|
$path = $_SERVER['DOCUMENT_ROOT'];
|
|
require($path . '/core/header.php');
|
|
|
|
?>
|
|
<div style="
|
|
margin: auto;
|
|
width: 350px;
|
|
padding-top: 100px;
|
|
">
|
|
<h1>register</h1>
|
|
<form action="/register.php" method="post" class="input-form">
|
|
<table>
|
|
<tr>
|
|
<td><b>username:</b></td>
|
|
<td>
|
|
<input name="user" type="text">
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td><b>password:</b></td>
|
|
<td>
|
|
<input name="pass" type="password">
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td><b>confirm password:</b></td>
|
|
<td>
|
|
<input name="confirm_pass" type="password">
|
|
</td>
|
|
</tr>
|
|
<!--
|
|
<tr>
|
|
<td><b>email:</b></td>
|
|
<td>
|
|
<input name="email" type="email">
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td><b>confirm email:</b></td>
|
|
<td>
|
|
<input name="confirm_email" type="email">
|
|
</td>
|
|
</tr>
|
|
-->
|
|
</table>
|
|
<br>
|
|
<button type="Submit">submit</button>
|
|
<?php
|
|
if(isset($_GET['login_failed'])) {
|
|
echo "<br><br>";
|
|
echo "<div class=\"error\">";
|
|
echo $_GET['login_failed'];
|
|
echo "</div>";
|
|
}
|
|
?>
|
|
</form>
|
|
</div>
|
|
<?php
|
|
require($path . '/core/footer.php');
|
|
# the end...
|
|
?>
|