-
Notifications
You must be signed in to change notification settings - Fork 0
/
register.php
49 lines (41 loc) · 1.68 KB
/
register.php
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
<?php
// Include init file
include 'init.php';
include 'connect.php';
require('template/header.php');
if (!isset($_POST['submit'])) {
// Show the form
include 'register_form.inc.php';
require_once('template/footer.php');
exit;
} else {
// Check if any of the fields are missing
if (empty($_POST['username']) || empty($_POST['password']) || empty($_POST['confirmpass']) || empty($_POST['email']) || empty($_POST['cemail'])) {
// Reshow the form with an error
$reg_error = 'One or more fields missing';
include 'register_form.inc.php';
require_once('template/footer.php');
exit;
}
// Check if the passwords match
if ($_POST['password'] != $_POST['confirmpass']) {
// Reshow the form with an error
$reg_error = 'Your passwords do not match';
include 'register_form.inc.php';
require_once('template/footer.php');
exit;
}
if ($_POST['email'] != $_POST['cemail']) {
// Reshow the form with an error
$reg_error = 'Email addresses do not match';
include 'register_form.inc.php';
require_once('template/footer.php');
exit;
}
// Everything is ok, register
user_register ($_POST['username'], $_POST['password'], $_POST['email']);
echo 'Thank you for registering, <a href="login.php">click here</a> to login.';
}
require_once('template/footer.php');
?>
<br>