Advertisement
Guest User

Untitled

a guest
Oct 23rd, 2016
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.88 KB | None | 0 0
  1. <?php
  2. require('php/config.php');
  3. require('php/functions.php');
  4. require('php/functions_forum.php');
  5.  
  6. if(isset($_GET['p']) AND !empty($_GET['p'])){
  7.     $parrain_uniqid = htmlspecialchars($_GET['p']);
  8.     $req_parrain = $bdd->prepare('SELECT id FROM membres WHERE uniqid = ?');
  9.     $req_parrain->execute(array($parrain_uniqid));
  10.     $parrain_exist = $req_parrain->rowCount();
  11.     if($parrain_exist == 1) {
  12.         $id_parrain = $req_parrain->fetch();
  13.         $id_parrain = $id_parrain['id'];
  14.     }
  15. }
  16.  
  17. if(isset($_POST['forminscription']))
  18. {
  19.     $pseudo = htmlspecialchars($_POST['pseudo']);
  20.     $mail = htmlspecialchars($_POST['mail']);
  21.     $mail2 = htmlspecialchars($_POST['mail2']);
  22.     $mdp = sha1($_POST['mdp']);
  23.     $mdp2 = sha1($_POST['mdp2']);
  24.  
  25.     if(!empty($_POST['pseudo']) AND !empty($_POST['mail']) AND !empty($_POST['mail2']) AND !empty($_POST['mdp']) AND !empty($_POST['mdp2']))
  26.     {
  27.         $pseudolength = strlen($pseudo);
  28.         if($pseudolength <= 255)
  29.         {
  30.             if($mail == $mail2)
  31.             {
  32.                 if(filter_var($mail, FILTER_VALIDATE_EMAIL))
  33.                 {
  34.                     $reqmail = $bdd->prepare("SELECT * FROM membres WHERE mail = ?");
  35.                     $reqmail->execute(array($mail));
  36.                     $mailexist = $reqmail->rowCount();
  37.                     if($mailexist == 0)
  38.                     {
  39.                         if($mdp == $mdp2)
  40.                         {
  41.                             $longueurKey = 15;
  42.                             $key = "";
  43.                             for($i=1;$i<$longueurKey;$i++) {
  44.                                 $key .= mt_rand(0,9);
  45.                             }
  46.  
  47.                             $insertmbr = $bdd->prepare("INSERT INTO membres(pseudo, mail, motdepasse, confirmkey, uniqid, id_parrain) VALUES(?, ?, ?, ?, ?, ?)");
  48.                             if(isset($id_parrain) AND !empty($id_parrain)) {
  49.                                 $insertmbr->execute(array($pseudo, $mail, $mdp, $key, uniqid(), $id_parrain));
  50.                             } else {
  51.                                 $insertmbr->execute(array($pseudo, $mail, $mdp, $key, uniqid(), 0));
  52.                             }
  53.  
  54.                             $header="MIME-Version: 1.0\r\n";
  55.                             $header.='From:"Forum Switch"<forumswitch@niloo.fr>'."\n";
  56.                             $header.='Content-Type:text/html; charset="uft-8"'."\n";
  57.                             $header.='Content-Transfer-Encoding: 8bit';
  58.  
  59.                             $message='
  60.                             <html>
  61.                                 <body>
  62.                                     <div align="center">
  63.                                         <a href="http://forumswitch.niloo.fr/confirmation.php?pseudo='.urlencode($pseudo).'&key='.$key.'">Confirmez votre compte !</a>
  64.                                     </div>
  65.                                 </body>
  66.                             </html>
  67.                             ';
  68.  
  69.                             mail($mail, "Confirmation de compte", $message, $header);
  70.  
  71.                             $erreur = "Votre compte a bien été créé ! <a href=\"connexion.php\">Me connecter</a>";
  72.                         }
  73.                         else
  74.                         {
  75.                             $erreur = "Vos mots de passes ne correspondent pas !";
  76.                         }
  77.                     }
  78.                     else
  79.                     {
  80.                         $erreur = "Adresse mail déjà utilisée !";
  81.                     }
  82.                 }
  83.                 else
  84.                 {
  85.                     $erreur = "Votre adresse mail n'est pas valide !";
  86.                 }
  87.             }
  88.             else
  89.             {
  90.                 $erreur = "Vos adresses mail ne correspondent pas !";
  91.             }
  92.         }
  93.         else
  94.         {
  95.             $erreur = "Votre pseudo ne doit pas dépasser 255 caractères !";
  96.         }
  97.     }
  98.     else
  99.     {
  100.         $erreur = "Tous les champs doivent être complétés !";
  101.     }
  102. }
  103. require('views/inscription.view.php');
  104. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement