forked from t4rsk1pp/cours-git-a2-exercice-web3
/
register.php
64 lines (52 loc) · 1.32 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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
<?php session_start();
require('config/config.php');
require('model/functions.fn.php');
/********************************
PROCESS
********************************/
if(isset($_POST) && !empty($_POST)) {
$email = $_POST['email'];
$password = $_POST['password'];
$username = $_POST['username'];
/* isEmailAvailable
return :
true if available
false if not available
$db -> database object
$email -> field value : email
*/
$email_ok = isEmailAvailable($db, $email);
/* isUsernameAvailable
return :
true if available
false if not available
$db -> database object
$username -> field value : username
*/
$username_ok = isUsernameAvailable($db, $username);
if ($email_ok && $username_ok) {
/* userRegistration
return :
true for registration OK
false for fail
$db -> database object
$username -> field value : username
$email -> field value : email
$password -> field value : password
*/
userRegistration($db, $username, $email, $password);
header('Location: login.php');
}
if (!$email_ok) {
$error='echec de l inscription';
}
if (!$username_ok) {
echo'reussite de l inscription';
}
}
/********************************
VIEW
********************************/
include 'view/_header.php';
include 'view/register.php';
include 'view/_footer.php';