Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- require('php/config.php');
- require('php/functions.php');
- require('php/functions_forum.php');
- if(isset($_GET['p']) AND !empty($_GET['p'])){
- $parrain_uniqid = htmlspecialchars($_GET['p']);
- $req_parrain = $bdd->prepare('SELECT id FROM membres WHERE uniqid = ?');
- $req_parrain->execute(array($parrain_uniqid));
- $parrain_exist = $req_parrain->rowCount();
- if($parrain_exist == 1) {
- $id_parrain = $req_parrain->fetch();
- $id_parrain = $id_parrain['id'];
- }
- }
- if(isset($_POST['forminscription']))
- {
- $pseudo = htmlspecialchars($_POST['pseudo']);
- $mail = htmlspecialchars($_POST['mail']);
- $mail2 = htmlspecialchars($_POST['mail2']);
- $mdp = sha1($_POST['mdp']);
- $mdp2 = sha1($_POST['mdp2']);
- if(!empty($_POST['pseudo']) AND !empty($_POST['mail']) AND !empty($_POST['mail2']) AND !empty($_POST['mdp']) AND !empty($_POST['mdp2']))
- {
- $pseudolength = strlen($pseudo);
- if($pseudolength <= 255)
- {
- if($mail == $mail2)
- {
- if(filter_var($mail, FILTER_VALIDATE_EMAIL))
- {
- $reqmail = $bdd->prepare("SELECT * FROM membres WHERE mail = ?");
- $reqmail->execute(array($mail));
- $mailexist = $reqmail->rowCount();
- if($mailexist == 0)
- {
- if($mdp == $mdp2)
- {
- $longueurKey = 15;
- $key = "";
- for($i=1;$i<$longueurKey;$i++) {
- $key .= mt_rand(0,9);
- }
- $insertmbr = $bdd->prepare("INSERT INTO membres(pseudo, mail, motdepasse, confirmkey, uniqid, id_parrain) VALUES(?, ?, ?, ?, ?, ?)");
- if(isset($id_parrain) AND !empty($id_parrain)) {
- $insertmbr->execute(array($pseudo, $mail, $mdp, $key, uniqid(), $id_parrain));
- } else {
- $insertmbr->execute(array($pseudo, $mail, $mdp, $key, uniqid(), 0));
- }
- $header="MIME-Version: 1.0\r\n";
- $header.='From:"Forum Switch"<forumswitch@niloo.fr>'."\n";
- $header.='Content-Type:text/html; charset="uft-8"'."\n";
- $header.='Content-Transfer-Encoding: 8bit';
- $message='
- <html>
- <body>
- <div align="center">
- <a href="http://forumswitch.niloo.fr/confirmation.php?pseudo='.urlencode($pseudo).'&key='.$key.'">Confirmez votre compte !</a>
- </div>
- </body>
- </html>
- ';
- mail($mail, "Confirmation de compte", $message, $header);
- $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 pseudo ne doit pas dépasser 255 caractères !";
- }
- }
- else
- {
- $erreur = "Tous les champs doivent être complétés !";
- }
- }
- require('views/inscription.view.php');
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement