Advertisement
Guest User

Untitled

a guest
May 25th, 2018
163
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 4.64 KB | None | 0 0
  1. <?php
  2.  
  3. include $_SERVER['DOCUMENT_ROOT'].'/Espace_membre/identification.php';
  4.  
  5. if(isset($_GET['p']) AND !empty($_GET['p'])){
  6.     $parrain_uniqid = htmlspecialchars($_GET['p']);
  7.     $req_parrain = $bdd->prepare('SELECT id FROM membres WHERE uniqid = ?');
  8.     $req_parrain->execute(array($parrain_uniqid));
  9.     $parrain_exist = $req_parrain->rowCount();
  10.     if($parrain_exist == 1) {
  11.         $id_parrain = $req_parrain->fetch();
  12.         $id_parrain = $id_parrain['id'];
  13.     }
  14. }
  15.  
  16. if(isset($_POST['forminscription']))
  17. {
  18.     $pseudo = htmlspecialchars($_POST['pseudo']);
  19.     $mail = htmlspecialchars($_POST['mail']);
  20.     $mail2 = htmlspecialchars($_POST['mail2']);
  21.     $mdp = sha1($_POST['mdp']);
  22.     $mdp2 = sha1($_POST['mdp2']);
  23.  
  24.     if(!empty($_POST['pseudo']) AND !empty($_POST['mail']) AND !empty($_POST['mail2']) AND !empty($_POST['mdp']) AND !empty($_POST['mdp2']))
  25.     {
  26.         $pseudolength = strlen($pseudo);
  27.         if($pseudolength <= 255)
  28.         {
  29.             if($mail == $mail2)
  30.             {
  31.                 if(filter_var($mail, FILTER_VALIDATE_EMAIL))
  32.                 {
  33.                     $reqmail = $bdd->prepare("SELECT * FROM membres WHERE mail = ?");
  34.                     $reqmail->execute(array($mail));
  35.                     $mailexist = $reqmail->rowCount();
  36.                     if($mailexist == 0)
  37.                     {
  38.                         if($mdp == $mdp2)
  39.                         {
  40.                             $longueurKey = 15;
  41.                             $key = "";
  42.                             for($i=1;$i<$longueurKey;$i++) {
  43.                                 $key .= mt_rand(0,9);
  44.                             }
  45.  
  46.                             $insertmbr = $bdd->prepare("INSERT INTO membres(pseudo, mail, motdepasse, confirmkey, uniqid, id_parrain) VALUES(?, ?, ?, ?, ?, ?)");
  47.                             if(isset($id_parrain) AND !empty($id_parrain)) {
  48.                                 $insertmbr->execute(array($pseudo, $mail, $mdp, $key, uniqid(), $id_parrain));
  49.                             } else {
  50.                                 $insertmbr->execute(array($pseudo, $mail, $mdp, $key, uniqid(), 0));
  51.                             }
  52.  
  53.                             $header="MIME-Version: 1.0\r\n";
  54.                             $header.='From:"PrimFX.com"<support@primfx.com>'."\n";
  55.                             $header.='Content-Type:text/html; charset="uft-8"'."\n";
  56.                             $header.='Content-Transfer-Encoding: 8bit';
  57.  
  58.                             $message='
  59.                             <html>
  60.                                 <body>
  61.                                     <div align="center">
  62.                                         <a href="/Espace_membre/confirmation.php?pseudo='.urlencode($pseudo).'&key='.$key.'">Confirmez votre compte !</a>
  63.                                     </div>
  64.                                 </body>
  65.                             </html>
  66.                             ';
  67.  
  68.                             mail($mail, "Confirmation de compte", $message, $header);
  69.  
  70.                             $erreur = "Votre compte a bien été créé ! <a href=\"connexion.php\">Me connecter</a>";
  71.                         }
  72.                         else
  73.                         {
  74.                             $erreur = "Vos mots de passes ne correspondent pas !";
  75.                         }
  76.                     }
  77.                     else
  78.                     {
  79.                         $erreur = "Adresse mail déjà utilisée !";
  80.                     }
  81.                 }
  82.                 else
  83.                 {
  84.                     $erreur = "Votre adresse mail n'est pas valide !";
  85.                 }
  86.             }
  87.             else
  88.             {
  89.                 $erreur = "Vos adresses mail ne correspondent pas !";
  90.             }
  91.         }
  92.         else
  93.         {
  94.             $erreur = "Votre pseudo ne doit pas dépasser 255 caractères !";
  95.         }
  96.     }
  97.     else
  98.     {
  99.         $erreur = "Tous les champs doivent être complétés !";
  100.     }
  101. }
  102.  
  103. ?>
  104. <html>
  105.     <head>
  106.         <title>TUTO PHP</title>
  107.         <meta charset="utf-8">
  108.     </head>
  109.     <body>
  110.         <div align="center">
  111.             <h2>Inscription</h2>
  112.             <br /><br />
  113.             <form method="POST" action="">
  114.                 <table>
  115.                     <tr>
  116.                         <td align="right">
  117.                             <label for="pseudo">Pseudo :</label>
  118.                         </td>
  119.                         <td>
  120.                             <input type="text" placeholder="Votre pseudo" id="pseudo" name="pseudo" value="<?php if(isset($pseudo)) { echo $pseudo; } ?>" />
  121.                         </td>
  122.                     </tr>
  123.                     <tr>
  124.                         <td align="right">
  125.                             <label for="mail">Mail :</label>
  126.                         </td>
  127.                         <td>
  128.                             <input type="email" placeholder="Votre mail" id="mail" name="mail" value="<?php if(isset($mail)) { echo $mail; } ?>" />
  129.                         </td>
  130.                     </tr>
  131.                     <tr>
  132.                         <td align="right">
  133.                             <label for="mail2">Confirmation du mail :</label>
  134.                         </td>
  135.                         <td>
  136.                             <input type="email" placeholder="Confirmez votre mail" id="mail2" name="mail2" value="<?php if(isset($mail2)) { echo $mail2; } ?>" />
  137.                         </td>
  138.                     </tr>
  139.                     <tr>
  140.                         <td align="right">
  141.                             <label for="mdp">Mot de passe :</label>
  142.                         </td>
  143.                         <td>
  144.                             <input type="password" placeholder="Votre mot de passe" id="mdp" name="mdp" />
  145.                         </td>
  146.                     </tr>
  147.                     <tr>
  148.                         <td align="right">
  149.                             <label for="mdp2">Confirmation du mot de passe :</label>
  150.                         </td>
  151.                         <td>
  152.                             <input type="password" placeholder="Confirmez votre mdp" id="mdp2" name="mdp2" />
  153.                         </td>
  154.                     </tr>
  155.                     <tr>
  156.                         <td></td>
  157.                         <td align="center">
  158.                             <br />
  159.                             <input type="submit" name="forminscription" value="Je m'inscris" />
  160.                         </td>
  161.                     </tr>
  162.                 </table>
  163.             </form>
  164.             <?php
  165.             if(isset($erreur))
  166.             {
  167.                 echo '<font color="red">'.$erreur."</font>";
  168.             }
  169.             ?>
  170.         </div>
  171.     </body>
  172. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement