Advertisement
Guest User

te

a guest
May 17th, 2017
590
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 9.42 KB | None | 0 0
  1. <!DOCTYPE html>
  2.  <?php
  3. session_start();
  4. $titre="profil";
  5. require_once('../config/configuration.php');
  6. require_once('../inc/head.php');
  7. include_once('../config/baseDonnees.php');
  8. include_once('../config/fonctions.php');
  9. require_once('../inc/header.php');
  10.  
  11. function random($car) {
  12. $string = "";
  13. $chaine = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
  14. srand((double)microtime()*1000000);
  15. for($i=0; $i<$car; $i++) {
  16. $string .= $chaine[rand()%strlen($chaine)];
  17. }
  18. return $string;
  19. }
  20. ?>
  21. <style>
  22.   div#form {
  23.    width:250px;
  24.  }
  25. </style>
  26. <?php
  27. if(isset($_POST['forminscription'])) {
  28.    $pseudo = htmlspecialchars($_POST['pseudo']);
  29.    $email = htmlspecialchars($_POST['mail']);
  30.    $mail2 = htmlspecialchars($_POST['mail2']);
  31.    $mdp = sha1($_POST['mdp']);
  32.    $mdp2 = sha1($_POST['mdp2']);
  33.    $time = time();
  34.    $reponse = htmlspecialchars($_POST['reponse']);
  35.    if(!empty($_POST['pseudo']) AND !empty($_POST['mail']) AND !empty($_POST['mail2']) AND !empty($_POST['mdp']) AND !empty($_POST['mdp2'])) {
  36.       $pseudolength = strlen($pseudo);
  37.       if($pseudolength <= 255) {
  38.          if($email == $mail2) {
  39.             if(filter_var($email, FILTER_VALIDATE_EMAIL)) {
  40.                $reqmail = $bdd->prepare("SELECT * FROM membres WHERE mail = ?");
  41.                $reqmail->execute(array($email));
  42.                $mailexist = $reqmail->rowCount();
  43.                if($mailexist == 0) {
  44.  $reqpseudo = $bdd->prepare("SELECT * FROM membres WHERE pseudo = ?");
  45.                $reqpseudo->execute(array($pseudo));
  46.                $pseudoexist = $reqpseudo->rowCount();
  47.                if($pseudoexist == 0) {
  48.                   if($mdp == $mdp2) {
  49.                      $longueurKey = 15;
  50.                      $key = "";
  51.                      for($i=1;$i<$longueurKey;$i++) {
  52.                         $key .= mt_rand(0,9);
  53.                      }
  54.                      $active= 0;
  55.                     $ip= $_SERVER['REMOTE_ADDR'];
  56.                        
  57.                         $chaine = random(5);
  58. $chaine1 = random(5);
  59. $chaine2 = random(5);
  60. $chaine3 = random(5);
  61. $chaine4 = random(5);
  62. $cle = "CRAFT-".$chaine."-".$chaine1."-".$chaine2."-".$chaine3."-".$chaine4."";
  63.                        
  64.                        
  65.                        
  66.                      $insertcle = $bdd->prepare("INSERT INTO cle(active, pseudo, cle, ip, email) VALUES(?, ?, ?, ?, ?)");
  67.                      $insertcle->execute(array($active, $pseudo, $cle, $ip, $email));
  68.                      
  69.                       $req = $bdd->prepare('SELECT * FROM cle WHERE pseudo = :inputSearch');
  70.                       $req->bindParam(':inputSearch', $pseudo, PDO::PARAM_STR, 100);
  71.                       $req->execute();
  72.                       $resultats = $req->fetch(PDO::FETCH_OBJ);
  73.                      
  74.                      $insertmbr = $bdd->prepare("INSERT INTO membres(pseudo, mail, motdepasse, confirmkey, uniqid, user_inscription, reponse, id_cle) VALUES(?, ?, ?, ?, ?, ?, ?, ?)");
  75.                      $insertmbr->execute(array($pseudo, $email, $mdp, $key, uniqid(), $time, $reponse, $resultats->id));
  76.  
  77.  
  78. include('../inc/phpmailer/PHPMailerAutoload.php'); //Si vous n'avez pas encore inclus PHPMailer  
  79. $mail = new PHPMailer;  
  80. $mail->isSMTP();  // Set mailer to use SMTP  
  81. $mail->Host = 'mail.nextwab.com';  //L'h&ocirc;te Mail de Nextwab    
  82. $mail->SMTPAuth = true;                                
  83. $mail->Username = 'anthony@admin.craftacms.com';                 //L'adresse mail que vous utilisez pour l'envoi du mail    
  84. $mail->Password = 'delgehier';                           //Le mot de passe de l'adresse mail que vous utilisez pour l'envoi du mail    
  85. $mail->SMTPSecure = 'tls';                              
  86. $mail->Port = 26;    $mail->setFrom('anthony@admin.craftacms.com', 'Craftacms');                           //Votre E-mail + Nom afficher en ent&ecirc;te !  
  87. $mail->addAddress(''.$email.'');             //L'adresse mail de votre destinataire    
  88. $mail->isHTML(true);  
  89. $mail->CharSet = "UTF-8"; //Encodage des caract&egrave;res au format UTF8  
  90. $mail->Subject = 'Confirmation de compte'; //Le sujet de votre mail  
  91. $mail->Body    = '
  92. <html>
  93.                        <body>
  94.                           <div align="center">
  95.                              <a href="http://127.0.0.1/Tutos%20PHP/%2314%20%28Espace%20membre%29/confirmation.php?pseudo='.urlencode($pseudo).'&key='.$key.'">Confirmez votre compte !</a>
  96.                           </div>
  97.                        </body>
  98.                     </html>
  99.  
  100. '; //Le contenu de votre mail.  
  101. $mail->AltBody = 'Votre messagerie n\'est pas compatible avec les mails HTML';  
  102.  
  103. $mail->SMTPOptions = array(  
  104.  'ssl' => array(  
  105.  'verify_peer' => false,  
  106.  'verify_peer_name' => false,  
  107.  'allow_self_signed' => true  
  108.  )  
  109. );  
  110.  
  111. if (!$mail->send()) {
  112.  
  113.    $show->showError("<center>Erreur lors de l'envoie du mail.</center>");
  114.  
  115.  
  116.  $show->showError("Mailer Error: ".$mail->ErrorInfo."");  
  117.  
  118. } else {  
  119.  
  120.    $show->showSuccess("<center>Compte créer.</center>");
  121. }  
  122.  
  123.  
  124.  
  125.  
  126.  
  127.                      $erreur = "Votre compte a bien été créé ! <a href=\"connexion.php\">Me connecter</a>";
  128.                   } else {
  129.                      $erreur = "Vos mots de passes ne correspondent pas !";
  130.                   }
  131.                   } else {
  132.                   $erreur = "Pseudo déjà utilisée !";
  133.                }
  134.               } else {
  135.                   $erreur = "Adresse mail déjà utilisée !";
  136.                }
  137.             } else {
  138.                $erreur = "Votre adresse mail n'est pas valide !";
  139.             }
  140.          } else {
  141.             $erreur = "Vos adresses mail ne correspondent pas !";
  142.          }
  143.       } else {
  144.          $erreur = "Votre pseudo ne doit pas dépasser 255 caractères !";
  145.       }
  146.    } else {
  147.       $erreur = "Tous les champs doivent être complétés !";
  148.    }
  149. }
  150. ?>
  151. <html>
  152.    <head>
  153.       <title>TUTO PHP</title>
  154.       <meta charset="utf-8">
  155.    </head>
  156.    <body>
  157.       <div align="center">
  158.          <h2>Inscription</h2>
  159.          <br /><br />
  160.          <form method="POST" action="">
  161.             <table>
  162.                <tr>
  163.                   <td align="right">
  164.                      <label for="pseudo">Pseudo :</label>
  165.                   </td>
  166.                   <td>
  167.                      <input type="text" placeholder="Votre pseudo" id="pseudo" name="pseudo" value="<?php if(isset($pseudo)) { echo $pseudo; } ?>" />
  168.                   </td>
  169.                </tr>
  170.                <tr>
  171.                   <td align="right">
  172.                      <label for="mail">Mail :</label>
  173.                   </td>
  174.                   <td>
  175.                      <input type="email" placeholder="Votre mail" id="mail" name="mail" value="<?php if(isset($mail)) { echo $mail; } ?>" />
  176.                   </td>
  177.                </tr>
  178.                <tr>
  179.                   <td align="right">
  180.                      <label for="mail2">Confirmation du mail :</label>
  181.                   </td>
  182.                   <td>
  183.                      <input type="email" placeholder="Confirmez votre mail" id="mail2" name="mail2" value="<?php if(isset($mail2)) { echo $mail2; } ?>" />
  184.                   </td>
  185.                </tr>
  186.                <tr>
  187.                   <td align="right">
  188.                      <label for="mdp">Mot de passe :</label>
  189.                   </td>
  190.                   <td>
  191.                      <input type="password" placeholder="Votre mot de passe" id="mdp" name="mdp" />
  192.                   </td>
  193.                </tr>
  194.                <tr>
  195.                   <td align="right">
  196.                      <label for="mdp2">Confirmation du mot de passe :</label>
  197.                   </td>
  198.                   <td>
  199.                      <input type="password" placeholder="Confirmez votre mdp" id="mdp2" name="mdp2" />
  200.                   </td>
  201.                </tr>
  202.                <tr>
  203.                   <td align="right">
  204.                      <label for="reponse">Question secrète</label>
  205.                   </td>
  206.                   <td>
  207.                    <select style="background: none repeat scroll 0% 0% border: 0; border-radius: 0; height: 45px; padding: 10px 20px;">
  208.                             <option style="background: none repeat scroll 0% 0%  border: 0; border-radius: 0; height: 45px; padding: 10px 20px;"><font color="black">Quel est le prénom de votre grand-mère?</option>
  209.                             <option style="background: none repeat scroll 0% 0%  border: 0; border-radius: 0; height: 45px; padding: 10px 20px;"><font color="black">Quel est votre ville de naissance?</option>
  210.                             <option style="background: none repeat scroll 0% 0%  border: 0; border-radius: 0; height: 45px; padding: 10px 20px;"><font color="black">Quel est le nom de votre chien?</option>
  211.                             <option style="background: none repeat scroll 0% 0%  border: 0; border-radius: 0; height: 45px; padding: 10px 20px;"><font color="black">Quel est votre livre préféré?</option>
  212.                         </select>
  213.                   </td>
  214.  
  215.                </tr>
  216.                <tr>
  217.                   <td align="right">
  218.                      <label for="reponse"></label>
  219.                   </td>
  220.                   <td>
  221.                      <input type="text" class="form-control" id="reponse" name="reponse" placeholder="Réponse secrète"  />
  222.                   </td>
  223.                </tr>
  224.                <tr>
  225.                   <td></td>
  226.                   <td >
  227.                      <br />
  228.                      <center><input type="submit" name="forminscription" value="Je m'inscris" /></center>
  229.                   </td>
  230.                </tr>
  231.             </table>
  232.          </form>
  233.          <?php
  234.          if(isset($erreur))
  235.          {
  236.             $show->showError("<font color='red'>".$erreur."</font>");  
  237.          }
  238.          ?>
  239.       </div>
  240.    </body>
  241. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement