-
Notifications
You must be signed in to change notification settings - Fork 0
/
signup.php
377 lines (277 loc) · 14.6 KB
/
signup.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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
<?php
include('assets/php/config.php');
// include("assets/PHPMailer/src/PHPmailer.php");
// include("assets/PHPMailer/src/SMTP.php");
// include("assets/PHPMailer/src/Exception.php");
// use PHPMailer\PHPMailer\PHPMailer;
// use PHPMailer\PHPMailer\Exception;
?>
<?php
// Si l'adresse mail n'est pas confirmée
$sql = "DELETE FROM users WHERE user_status='0'";
$stmt = $db->prepare($sql);
$stmt->execute();
if( !func::checkLoginState($db) ){
if( isset($_POST['last_name']) && isset($_POST['first_name']) && isset($_POST['email']) && isset($_POST['username']) && isset($_POST['pswd']) && isset($_POST['pswd_confirm']) ) {
$last_name = htmlspecialchars($_POST['last_name']);
$first_name = htmlspecialchars($_POST['first_name']);
$username = htmlspecialchars($_POST['username']);
$email = htmlspecialchars($_POST['email']);
$birth_day = htmlspecialchars($_POST['birth_day']);
$birth_month = htmlspecialchars($_POST['birth_month']);
$birth_year = htmlspecialchars($_POST['birth_year']);
$birthday = $birth_day.'/'.$birth_month.'/'.$birth_year;
$password = htmlspecialchars($_POST['pswd']);
$password_repeat = htmlspecialchars($_POST['pswd_confirm']);
$hashed_password = password_hash($password,PASSWORD_DEFAULT);
if($password != $password_repeat){
redirect('signup.php');
} else {
// $email=$_POST['email'];
$query = "SELECT * FROM users WHERE user_email = '$email'";
$stmt = $db->prepare($query);
$stmt->execute();
$row = $stmt->fetch(PDO::FETCH_ASSOC);
// Si l'email est déjà pris
if(!!$row){
redirect("signup.php?email=false");
} else {
// Si le pseudo est déjà pris
if(!!$row){
redirect("signup.php?pseudo=false");
}else{
$code = random_int(100000, 999999);
$query = "INSERT INTO users (user_lastname,user_firstname,user_username,user_email,user_password,user_birthday,user_status,user_CGU,user_email_verify) VALUES ('$last_name','$first_name','$username','$email','$hashed_password','$birthday',0,1,'$code')";
$stmt = $db->prepare($query);
$stmt->execute();
// mail($email, 'Confirmation de l\'adresse e-mail', "Voici le code pour confirmer ton adresse e-mail : ".$code);
redirect("email_verify.php?client_email=$email");
}
}
}
} else {
makeVisible('main.main_content',true);
}
} else {
redirect('index.php');
}
?>
<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>REAH | Inscription</title>
<link rel="stylesheet" href="assets/css/styles.css">
<link rel="stylesheet" href="assets/css/inscription.css">
<link href="https://fonts.googleapis.com/css2?family=Montserrat&display=swap" rel="stylesheet">
<style>
body {
background: black;
}
</style>
</head>
<body>
<a href="fil_actu.php" class="reah_logo">
<img src="sources/img/dark_reah_logo.png" alt="">
</a>
<main class="main_content" style="visibility:hidden;">
<?php
if (isset($_GET['email'])) {
echo'<p class="message_false_container">L\'email saisi est déjà utilisé.</p>';
}
// else {
// echo'<p class="message_true_container">Un mail a été envoyé à '.$_GET['email'].' afin de vérifier que vous en êtes le titulaire.</p>';
// }
if (isset($_GET['pseudo'])) {
echo'<p class="message_false_container">Le pseudo saisi est déjà pris.</p>';
}
?>
<!-- Background video -->
<video class="background_video" poster="" autoplay loop muted>
<source src="sources/video/videobackPT.mp4" type="video/mp4">
</video>
<!-- Message to fulfil all the conditions necessarys -->
<div class="alert_message_container">
<div class="alert_message hide"></div>
</div>
<!-- Form part 1-->
<form id="form1" action="" method="POST">
<div class="form_container">
<!-- Google button -->
<div class="btn google_btn">S'inscrire avec Google</div>
<!-- "Or" section -->
<div class="ou_section">
<div class="line"></div>
<p>OU</p>
<div class="line"></div>
</div>
<!-- Input last name -->
<div class="input_container">
<label for="last_name">
<span>Nom</span>
<input type="text" class="input_connexion first_form" name="last_name" id="last_name" required>
</label>
</div>
<!-- Input first name -->
<div class="input_container">
<label for="first_name">
<span>Prénom</span>
<input type="text" class="input_connexion first_form" name="first_name" id="first_name"
required>
</label>
</div>
<!-- Select birth day -->
<div class="select_container">
<!-- Day -->
<select name="birth_day" class="first_form" required>
<option value="" selected="selected" disabled>JJ</option>
<?php
for($i = 1; $i < 32; $i++)
{
echo "<option value=\"$i\">". str_pad($i, 2, '0', STR_PAD_LEFT) ."</option>";
}
?>
</select>
<!-- Month -->
<select name="birth_month" class="first_form" required>
<option value="" selected="selected" disabled>MM</option>
<?php
for($i = 1; $i < 13; $i++)
{
echo "<option value=\"$i\">". str_pad($i, 2, '0', STR_PAD_LEFT) ."</option>";
}
?>
</select>
<!-- Year -->
<select name="birth_year" class="first_form" required>
<option value="" selected="selected" disabled>AAAA</option>
<?php
for($i = date('Y') - 16; $i > 1899; $i--)
{
echo "<option value=\"$i\">$i</option>";
}
?>
</select>
</div>
<!-- Button next -->
<div class="btn btn_next cannot_click">Suivant <span class="btn_next_remplissage"></span></div>
<a href="login.php" class="link">J'ai déjà un compte !</a>
</div>
<!-- Form part 2 -->
<div class="form_container2 fadeOut1">
<!-- Back arrow -->
<svg class="btn_prev" xmlns="http://www.w3.org/2000/svg" width="31.621" height="25.241"
viewBox="0 0 31.621 25.241">
<g class="fleche" id="Groupe_12" data-name="Groupe 12" transform="translate(-754.379 -406.379)">
<line class="line" id="Ligne_12" data-name="Ligne 12" x1="0" x2="27"
transform="translate(756.5 418.5)" fill="none" stroke="#efe4ef" stroke-linecap="round"
stroke-width="3" />
<line class="line" id="Ligne_13" data-name="Ligne 13" y1="10" x2="10"
transform="translate(756.5 408.5)" fill="none" stroke="#efe4ef" stroke-linecap="round"
stroke-width="3" />
<line class="line" id="Ligne_14" data-name="Ligne 14" x2="10" y2="10.9"
transform="translate(756.5 418.6)" fill="none" stroke="#efe4ef" stroke-linecap="round"
stroke-width="3" />
</g>
</svg>
<!-- Input email -->
<div class="input_container">
<label for="email">
<span>E-mail</span>
<input type="email" class="input_connexion second_form" name="email" id="email" required>
</label>
</div>
<!-- Input username -->
<div class="input_container">
<label for="username">
<span>Pseudo</span>
<input type="text" class="input_connexion second_form" name="username" id="username" required>
</label>
</div>
<!-- Input password -->
<div class="input_container">
<label for="pswd">
<span>Mot de passe</span>
<input type="password" id="input_mdp" class="input_connexion input_mdp second_form" name="pswd"
id="psdw" required autocomplete="off" onclick="restrictionMdp()">
</label>
<!-- To see the password -->
<div class="icon_eye" id="eye" alt=""></div>
<!-- Restriction -->
<!-- Icon restriction -->
<img class="icon_restriction" src="sources/img/restriction.svg" alt="">
<!-- Message restriction -->
<div class="restriction_container">
<p class="restriction">- 8 caractères minimum <br> - 1 majuscule au minimum </p>
</div>
</div>
<!-- Intput password confirmation -->
<div class="input_container">
<label for="pswd">
<span>Confirmation du mot de passe</span>
<input type="password" id="input_mdp_validation"
class="input_connexion second_form input_mdp_verif" name="pswd_confirm" required
autocomplete="off">
</label>
</div>
<!-- Accept CGU -->
<div class="checkbox_container">
<input id="CGU" type="checkbox" class="CGU_checkbox second_form" value="accepted" name="cgu"
required>
<label for="CGU" class="CGU_label">J'ai lu et j'accepte les <a href="cgu.php" class="link"> conditions
générales d'utilisation</a></label>
</div>
<!-- Inscription button -->
<button class="btn btn_inscription cannot_click" type="submit">S'inscrire</button>
</div>
</form>
<!-- Form n°2 -->
<!--⬇ En suspens, à mettre dans la page "email_verif.php" ⬇-->
<!-- <form id="form2">
<div class="form_container3"> -->
<!-- Back arrow -->
<!-- <svg class="btn_prev2" xmlns="http://www.w3.org/2000/svg" width="31.621" height="25.241"
viewBox="0 0 31.621 25.241">
<g class="fleche" id="Groupe_12" data-name="Groupe 12" transform="translate(-754.379 -406.379)">
<line class="line2" id="Ligne_12" data-name="Ligne 12" x1="0" x2="27"
transform="translate(756.5 418.5)" fill="none" stroke="#efe4ef" stroke-linecap="round"
stroke-width="3" />
<line class="line2" id="Ligne_13" data-name="Ligne 13" y1="10" x2="10"
transform="translate(756.5 408.5)" fill="none" stroke="#efe4ef" stroke-linecap="round"
stroke-width="3" />
<line class="line2" id="Ligne_14" data-name="Ligne 14" x2="10" y2="10.9"
transform="translate(756.5 418.6)" fill="none" stroke="#efe4ef" stroke-linecap="round"
stroke-width="3" />
</g>
</svg> -->
<!-- Input validation code -->
<!-- <p id="mail">Entre le code de validation envoyé à : <span class="mailcontainer"></span> </p>
<div class="input_confirm_container">
<input class="input_connexion input_confirm third_form" type="text" pattern="[0-9]{1}" name="code1"
required>
<input class="input_connexion input_confirm third_form" type="text" pattern="[0-9]{1}" name="code2"
required>
<input class="input_connexion input_confirm third_form" type="text" pattern="[0-9]{1}" name="code3"
required>
<input class="input_connexion input_confirm third_form" type="text" pattern="[0-9]{1}" name="code4"
required>
<input class="input_connexion input_confirm third_form" type="text" pattern="[0-9]{1}" name="code5"
required>
<input class="input_connexion input_confirm third_form" type="text" pattern="[0-9]{1}" name="code6"
required>
</div> -->
<!-- Link haven't received the code. -->
<!-- <a href="" class="link">Je n'ai pas reçu de code</a> -->
<!-- Validation button -->
<!-- <button class="btn btn_connexion cannot_click">Valider</button>
</div>
</form> -->
<!-- CGU -->
<a href="cgu.php" class="CGU">CGU<a>
</main>
<script type="text/javascript" src="assets/js/libraries/jquery/jquery.min.js"></script>
<script src="assets/js/app.js"></script>
<script src="assets/js/register.js"></script>
</body>
</html>