Added an error message thingy to the registration form
This commit is contained in:
parent
351004de44
commit
cfda6f6377
|
@ -13,6 +13,12 @@ body {
|
|||
div.main {
|
||||
}
|
||||
|
||||
div.error {
|
||||
border: 1px solid #ef5350;
|
||||
background-color: #ff867c;
|
||||
padding: 5px;
|
||||
}
|
||||
|
||||
/* stuff for input's like the login and post forms */
|
||||
form.input-form {
|
||||
}
|
||||
|
|
35
register.php
35
register.php
|
@ -7,13 +7,29 @@
|
|||
# #
|
||||
# - # - # - # - # - # - # - #
|
||||
|
||||
//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");
|
||||
|
||||
}
|
||||
|
||||
$path = $_SERVER['DOCUMENT_ROOT'];
|
||||
include($path . '/core/header.php');
|
||||
require($path . '/core/header.php');
|
||||
?>
|
||||
<div style="
|
||||
margin: auto;
|
||||
|
@ -21,7 +37,7 @@ include($path . '/core/header.php');
|
|||
padding-top: 100px;
|
||||
">
|
||||
<h1>register</h1>
|
||||
<form action="login.php" class="input-form">
|
||||
<form action="/register.php" method="post" class="input-form">
|
||||
<table>
|
||||
<tr>
|
||||
<td><b>username:</b></td>
|
||||
|
@ -41,6 +57,7 @@ include($path . '/core/header.php');
|
|||
<input name="confirm_pass" type="password">
|
||||
</td>
|
||||
</tr>
|
||||
<!--
|
||||
<tr>
|
||||
<td><b>email:</b></td>
|
||||
<td>
|
||||
|
@ -53,11 +70,21 @@ include($path . '/core/header.php');
|
|||
<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
|
||||
include($path . '/core/footer.php');
|
||||
require($path . '/core/footer.php');
|
||||
# the end...
|
||||
?>
|
||||
|
|
Loading…
Reference in New Issue