Vous pouvez tester le code pour me dire où j'ai fait l'erreur merci d'avance.
Code : Tout sélectionner
<!DOCTYPE html><html>
<head>
<meta charset="utf-8">
<title>Inscription</title>
</head>
<body align="center">
<h2>Inscription</h2>
<br />
<form method="POST">
<table align="center">
<tr>
<td align="right">
<label for="pseudo" >Pseudo :</label>
</td>
<td>
<input type="text" placeholder="Votre pseudo" id="pseudo" name="pseudo" value="<?php if(isset($pseudo)) { echo $pseudo; } ?>" />
</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="register" value="Je m'inscris" />
</td>
</tr>
</table>
<?php
$bdd = new PDO('mysql:host=127.0.0.1;dbname=espace_membres', 'root', ''); //Connexion a la bdd.
if(isset($_POST['register']))
{
$pseudo = htmlspecialchars(trim($_POST['pseudo'])); // Votre pseudo
$mail = htmlspecialchars(trim($_POST['mail'])); // Votre email
$mail2 = htmlspecialchars(trim($_POST['mail2'])); // Confirmation
$mdp = sha1($_POST['mdp']);// MDP
$mdp2 = sha1($_POST['mdp2']);// Confirmation
if(!empty($_POST['pseudo']) AND !empty($_POST['mail']) AND !empty($_POST['mail2']) AND !empty($_POST['mdp']) AND !empty($_POST['mdp2'])) // Check if all fields are full
{
$pseudolength = strlen($pseudo);
if($pseudolength <= 25) { // Pseudo less than 25 characters.
if($mail == $mail2) // If the mail entered matches the confirmation
{
if(filter_var($mail, FILTER_VALIDATE_EMAIL))
{
$reqmail = $bdd->prepare("SELECT * FROM membres WHERE mail = ?"); // Checks if the mail doesnt exist already in the database
$reqmail->execute(array($mail));
$mailexist = $reqmail->rowCount();
if($mailexist == 0) // If the mail already exists
{
if($mdp == $mdp2) // If the mdp entered matches the confirmation
{
$insertmbr = $bdd->prepare("INSERT INTO membres(pseudo, mail, motdepasse) VALUES(?, ?, ?)"); // Write in the database
$insertmbr->execute(array($pseudo, $mail, $mdp));
}
else // error_get_last(oid)
$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 pseudo ne doit pas dépasser 255 caractères !";
}
}
else
{
$erreur = "Tous les champs doivent être complétés !";
}
if(isset($erreur)) {
echo $erreur; }
else
echo "Félicitiations ! Vous êtes maintenant inscrit"
?>
</form>
</body>
</html>