Bonjour,
J'ai créé ma page d'inscription et j'aimerai une fois que l'inscription à été effectué qu'il y est une redirection vers une autre de mes page html.
Voici le code de ma page d'inscription
<?php
//--------------------------------------//
// Pour afficher les erreurs PHP
//--------------------------------------//
error_reporting(E_ALL);
//--------------------------------------//
//On importe la connexion à la BDD
//--------------------------------------//
require_once 'cnxBDD.php';
//--------------------------------------//
//Récupération "propre" des variables
// AVANT de les utiliser :
//--------------------------------------//
$pseudo = !empty($_POST['pseudo']) ? htmlspecialchars($_POST['pseudo']) : NULL ;
$mdp = !empty($_POST['mdp']) ? htmlspecialchars($_POST['mdp']) : NULL ;
$mdp2 = !empty($_POST['mdp2']) ? htmlspecialchars($_POST['mdp2']) : NULL ;
$mail = !empty($_POST['mail']) ? htmlspecialchars($_POST['mail']) : NULL ;
$mail2 = !empty($_POST['mail2']) ? htmlspecialchars($_POST['mail2']) : NULL ;
//--------------------------------------//
// Traitement du submit :
//--------------------------------------//
if(isset($_POST['forminscription'])) {
if( $pseudo && $mdp && $mdp2 && $mail && $mail2){
$pseudolenght = strlen($pseudo);
if($pseudolenght <= 255) {
if($mail == $mail2) {
if(filter_var($mail, FILTER_VALIDATE_EMAIL )) {
if($mdp == $mdp2) {
try{
$sql = "INSERT INTO membres (pseudo,mail,motdepasse)
VALUES (:pseudo,:mail,:motdepasse)";
$params = array(":pseudo"=>$pseudo,":mail"=>$mail,":motdepasse"=>$mdp);
$prepare = $bdd->prepare($sql);
$prepare->execute($params);
}catch(Exception $e) {
echo "<pre><br>".$e->getMessage()."<br>";
echo "</pre>";
exit;
}
} else {
$erreur = "Vos mots de passes ne correspondent pas";
}
} 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 ";
}
}
//--------------------------------------//
?>
<html>
<head>
<title>Inscription</title>
<link rel="icon" type="image/png" href="logo.png" />
<link rel="stylesheet" href="styleins.css" />
</head>
<body><center>
<div>
<h2>Inscription</h2>
<br /><br />
<form method="POST" action="">
<table>
<tr>
<td>
<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>
</table>
<table>
<tr>
<td >
<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>
</table>
<table>
<tr>
<td >
<label for="mail2">Confirmation du mail :</label>
</td>
<td>
<input type="email"
placeholder="Confirmer votre mail" id="mail2" name="mail2" "<?php if(isset($mail)) {echo $mail2;}?> "/>
</td>
</tr>
</table>
<table>
<tr>
<td >
<label for="mdp">Mot de passe :</label>
</td>
<td>
<input type="password"
placeholder="Votre mot de passe" id="mdp" name="mdp" />
</td>
</tr>
</table>
<table>
<tr>
<td >
<label for="mdp2">Confirmation du mot de passe :</label>
</td>
<td>
<input type="password"
placeholder="Confirmer votre mot de passe" id="mdp2" name="mdp2" />
</td>
</tr>
<tr>
<td></td>
<td>
<br />
<input type="submit" name="forminscription" value="Je m'inscris" />
</td>
</tr>
</table>
</form>
<?php
if(isset($erreur))
{
echo $erreur;
}
?>
</div>
</body></center>
</html>
Merci