-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInsertion_compte.php
More file actions
49 lines (45 loc) · 2.19 KB
/
Insertion_compte.php
File metadata and controls
49 lines (45 loc) · 2.19 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
<?php
session_start();
require_once("Connexion.php");
if (isset($_POST['pseudo']) && isset($_POST['email']) && isset($_POST['password']) && isset($_POST['confirmpassword'])) {
$pseudo = htmlspecialchars($_POST['pseudo']);
$email = htmlspecialchars($_POST['email']);
$password = htmlspecialchars($_POST['password']);
$confirmpassword = htmlspecialchars($_POST['confirmpassword']);
$image = htmlspecialchars($_POST['image']);
$sql = "SELECT pseudo, email FROM utilisateurs WHERE email= ? ";
$result = $bd->prepare($sql);
$result->execute(array($email));
$data = $result->fetch();
$row = $result->rowCount();
if ($row == 0) {
if (strlen($pseudo) <= 100) {
if (strlen($email) <= 100) {
if (filter_var($email, FILTER_VALIDATE_EMAIL)) {
if ($password == $confirmpassword) {
$password = hash('sha256',$password);
//$ip = $_SERVER['REMOTE_ADDR'];
$insert = $bd->prepare('INSERT INTO utilisateurs VALUES (NULL, :pseudo, :email, :password, :image)');
$insert->bindValue(':pseudo',$_POST['pseudo'], PDO::PARAM_STR);
$insert->bindValue(':email',$_POST['email'], PDO::PARAM_STR);
$insert->bindValue(':password',$_POST['password'], PDO::PARAM_STR);
$insert->bindValue(':image',$_POST['image'], PDO::PARAM_STR);
$insert->execute();
header('Location:Compte.php?reg_err=success');
}
else
header('Location:Compte.php?reg_err=password');
}
else
header('Location:Compte.php?reg_err=email');
}
else
header('Location:Compte.php?reg_err=email_length');
}
else
header('Location:Compte.php?reg_err=pseudo_length');
}
else
header('Location:Compte.php?reg_err=already');
}
?>