-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathformulaire.php
105 lines (86 loc) · 3.65 KB
/
formulaire.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
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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
<?php
/*require 'connect.php';*/
require 'db.php';
if(!empty($_POST)){
$firstname = ($_POST["firstname"]);
$lastname = $_POST["lastname"];
$address = $_POST["address"];
$zipcode = ($_POST["zipcode"]);
$city = $_POST["city"];
$country = $_POST["country"];
$phone = $_POST["phone"];
$email = ($_POST["email"]);
$password = $_POST["password"];
$passwordVerif = $_POST["password_verif"];
if (!empty($email) && !empty($password)){
require_once 'db.php';
$sql1 = "SELECT * FROM users WHERE `email`= ?";
$statement1 = $pdo->prepare($sql1);
$statement1->execute([$email]);
$usermail = $statement1->fetch();
if(!$usermail){
if(strlen($password) <= 10 && strlen($password) >= 5){
if($password === $passwordVerif){
$password = password_hash($password, PASSWORD_BCRYPT);
require_once 'db.php';
$sql2 = 'INSERT INTO users (`firstname`, `lastname`, `address`, `zipcode`, `city`, `country`, `phone`, `email`, `password`) VALUES (:firstname, :lastname, :address, :zipcode, :city, :country, :phone, :email, :password)';
$statement2 = $pdo->prepare($sql2);
$result = $statement2->execute([
":firstname" => $firstname,
":lastname" => $lastname,
":address" => $address,
":zipcode" => $zipcode,
":city" => $city,
":country" => $country,
":phone" => $phone,
":email" => $email,
":password" => $password]);
if($result){
$_SESSION["connect"] = true;
$_SESSION["username"] = $username;
header("Location: page.php");
}else{
die("erreur enregistrement en bdd");
// TODO : signaler erreur
}
}else{
die("mdp différents");
// TODO : signaler que mdp non identiques
}
}else{
// TODO : signaler que mdp est pas d'un bon format
die("mdp pas bon format");
}
}else{
die("utilisateur existe");
// TODO : signaler que username existe
}
}else{
// TODO : signaler les champs vides
}
}
?>
<section class="form">
<form method="POST" action="">
<label for="prenom">Prénom</label>
<input type="text" name="firstname" required>
<label for="nom">Nom de famille</label>
<input type="text" name="lastname" required>
<label for="address">Adresse</label>
<input type="text" name="address" required>
<label for="zipcode">Code Postal</label>
<input type="text" name="zipcode" required>
<label for="ville">Ville</label>
<input type="text" name="city" required>
<label for="pays">Pays</label>
<input type="text" name="country" required>
<label for="phone">Téléphone</label>
<input type="text" name="phone" required>
<label for="email">Adresse email</label>
<input type="email" name="email" required>
<label for="password">Mot de passe</label>
<input type="password" name="password" required>
<label for="password">Verification mot de passe</label>
<input type="password" name="password_verif" required>
<input class="button" type="submit" name="submit_c" value="S'inscrire">
</form>