-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsubmitCreateAccount.php
More file actions
90 lines (87 loc) · 3.69 KB
/
submitCreateAccount.php
File metadata and controls
90 lines (87 loc) · 3.69 KB
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
<?php
require_once 'config.php';
if (
isset($_POST['Nom']) &&
isset($_POST['prenom']) &&
isset($_POST['pseudo']) &&
isset($_POST['tel']) &&
isset($_POST['email']) &&
isset($_POST['password']) &&
isset($_POST['password_retype'])
) {
$Nom = htmlspecialchars($_POST['Nom']);
$prenom = htmlspecialchars($_POST['prenom']);
$pseudo = htmlspecialchars($_POST['pseudo']);
$tel = htmlspecialchars($_POST['tel']);
$email = htmlspecialchars($_POST['email']);
$mdp = htmlspecialchars($_POST['password']);
$password_retype = htmlspecialchars($_POST['password_retype']);
try {
$check = $bdd->prepare(
'SELECT username, email, mdp FROM users WHERE email = ?'
);
$check->execute([$email]);
$data = $check->fetch();
} catch (Exception $e) {
die('Erreur : ' . $e->getMessage());
}
$row = $check->rowCount();
if ($row == 0) {
if (strlen($Nom) <= 30) {
if (strlen($prenom) <= 50) {
if (strlen($pseudo) <= 30) {
if (strlen($tel) <= 10) {
if (strlen($email) <= 50) {
if (filter_var($email, FILTER_VALIDATE_EMAIL)) {
if ($mdp == $password_retype) {
$mdp = hash('sha256', $mdp);
try {
$insert = $bdd->prepare(
'INSERT INTO users (nom, prenom, email, username, mdp, telephone) VALUES (:Nom, :prenom, :email,:username, :mdp, :tel)'
);
$insert->execute([
'Nom' => $Nom,
'prenom' => $prenom,
'email' => $email,
'username' => $pseudo,
'mdp' => $mdp,
'tel' => $tel,
]);
} catch (Exception $e) {
die('Erreur : ' . $e->getMessage());
}
header(
'Location:createAccount.php?reg_err=success'
);
} else {
header(
'Location:createAccount.php?reg_err=password'
);
}
} else {
header(
'Location:createAccount.php?reg_err=email'
);
}
} else {
header(
'Location:createAccount.php?reg_err=email_length'
);
}
} else {
header('Location:createAccount.php?reg_err=tel');
}
} else {
header('Location:createAccount.php?reg_err=pseudo');
}
} else {
header('Location:createAccount.php?reg_err=prenom');
}
} else {
header('Location:createAccount.php?reg_err=Nom');
}
} else {
header('Location:createAccount.php?reg_err=already');
}
}
?>