Salut, je teste ce script et je n'arrive pas à comprendre pourquoi les champs ne veulent pas s'inscrire dans la bdd ...
Si quelqu'un a une idée du bug, je le remercie ;-)
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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 <?php $bdd = new PDO('mysql:host=creddre.mysql.db;dbname=treza', 'rezach', 'MDP'); if(isset($_POST['forminscription'])) { $nom = htmlspecialchars($_POST['nom']); $mail = htmlspecialchars($_POST['mail']); $mail2 = htmlspecialchars($_POST['mail2']); $mdp = sha1($_POST['mdp']); $mdp2 = sha1($_POST['mdp2']); if(!empty($_POST['nom']) AND !empty($_POST['mail']) AND !empty($_POST['mail2']) AND !empty($_POST['mdp']) AND !empty($_POST['mdp2'])) { $pseudolength = strlen($nom); if($pseudolength <= 255) { if($mail == $mail2) { if(filter_var($mail, FILTER_VALIDATE_EMAIL)) { $reqmail = $bdd->prepare("SELECT * FROM members WHERE mail = ?"); $reqmail->execute(array($mail)); $mailexist = $reqmail->rowCount(); if($mailexist == 0) { if($mdp == $mdp2) { $insertmbr = $bdd->prepare("INSERT INTO members(nom, email, password) VALUES($nom, $mail, $mdp)"); $insertmbr->execute(array($nom, $mail, $mdp)); $erreur = "Votre compte a bien été créé ! <a href=\"connexion.php\">Me connecter</a>"; } else { $erreur = "Vos mots de passes ne correspondent pas !"; } } else { $erreur = "Adresse mail déjà utilisée !"; } } else { $erreur = "Votre adresse mail n'est pas valide !"; } } else { $erreur = "Vos adresses mail ne correspondent pas !"; } } else { $erreur = "Votre nom ne doit pas dépasser 255 caractères !"; } } else { $erreur = "Tous les champs doivent être complétés !"; } } ?> <html> <head> <title>TUTO PHP</title> </head> <body> <div align="center"> <h2>Inscription</h2> <br /><br /> <form method="POST" action=""> <table> <tr> <td align="right"> <label for="nom">nom :</label> </td> <td> <input type="text" placeholder="Votre nom" id="nom" name="nom" value="<?php if(isset($nom)) { echo $nom; } ?>" /> </td> </tr> <tr> <td align="right"> <label for="mail">Mail :</label> </td> <td> <input type="email" placeholder="Votre mail" id="mail" name="mail" value="<?php if(isset($mail)) { echo $mail; } ?>" /> </td> </tr> <tr> <td align="right"> <label for="mail2">Confirmation du mail :</label> </td> <td> <input type="email" placeholder="Confirmez votre mail" id="mail2" name="mail2" value="<?php if(isset($mail2)) { echo $mail2; } ?>" /> </td> </tr> <tr> <td align="right"> <label for="mdp">Mot de passe :</label> </td> <td> <input type="password" placeholder="Votre mot de passe" id="mdp" name="mdp" /> </td> </tr> <tr> <td align="right"> <label for="mdp2">Confirmation du mot de passe :</label> </td> <td> <input type="password" placeholder="Confirmez votre mdp" id="mdp2" name="mdp2" /> </td> </tr> <tr> <td></td> <td align="center"> <br /> <input type="submit" name="forminscription" value="Je m'inscris" /> </td> </tr> </table> </form> <?php if(isset($erreur)) { echo '<font color="red">'.$erreur."</font>"; } ?> </div> </body> </html>
Partager