/
process_register.php
34 lines (28 loc) · 1015 Bytes
/
process_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
<?php
require_once 'bootstrap.php';
# Get values of variables
$username = $_POST['username'];
$password = $_POST['password'];
$retype = $_POST['retype'];
if ($username == '' || $password == '' || $retype == '') {
addFlashMessage('All fields must be filled in order to register <br/>');
redirect("index.php");
}
if ($password !== $retype) {
addFlashMessage('Provided passwords have to be identical <br/>');
redirect("index.php");
}
$existance = userExistance($username);
if ($existance != 0) {
addFlashMessage('You are known here, no need to introduce again. <br/>');
redirect("index.php");
}
try {
$adduser = "INSERT INTO users (Username, Password) VALUES (:username,:password)";
$prepare_add_user_querry = $database->prepare($adduser);
$prepare_add_user_querry->execute(array(':username' => $username, ':password' => md5($password)));
} catch (PDOException $exception) {
echo $exception->getMessage();
}
addFlashMessage('We will remember you!');
redirect("index.php");