Advertisement
Guest User

Untitled

a guest
Jul 27th, 2017
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 5.45 KB | None | 0 0
  1. <!-- Inscription -->
  2.         <div id="registration">
  3.                
  4. <?php
  5. // Si la demande submit n'a pas été envoyé
  6. if(!isset($_POST['submit_inscription']))  // Si la ligne 47 est a FALSE
  7. {
  8. /*==========================================================================\
  9. |                                                                           |
  10. |         PARTIE FORMUALAIRE POUR L'ENREGISTREMENT D'UN NEW ACCOUNT         |
  11. |                                                                           |
  12. \==========================================================================*/
  13. ?>
  14.     <form action="<?php echo $_SERVER["PHP_SELF"]; ?>?location=register" method="post">
  15.     <table>
  16.         <tr>
  17.             <td>
  18.                 <p>Nom de compte :<br />
  19.                 <input name="account" type="text"></p>
  20.             </td>
  21.             <td>
  22.                 <p>Adresse e-mail :<br />
  23.                 <input name="email" type="text"></p>
  24.             </td>
  25.         </tr>
  26.         <tr>
  27.             <td>
  28.                 <p>Mot de passe :<br />
  29.                 <input name="password" type="password"></p>
  30.             </td>
  31.             <td>
  32.                 <p>Confirmer mot de passe :<br />
  33.                 <input name="conf_password" type="password"></p>
  34.             </td>
  35.         </tr>
  36.         <tr>
  37.             <td>
  38.                 <p>Question secr&egrave;te :<br />
  39.                 <input name="question" type="text"></p>
  40.             </td>
  41.             <td>
  42.                 <p>R&eacute;ponse &agrave; la question :<br />
  43.                 <input name="reponse" type="text"></p>
  44.             </td>
  45.         </tr>
  46.     </table>
  47.    
  48.     <p><input class="submit" name="submit_inscription" value="Envoyer" type="submit"></p>
  49.     </form>
  50. <?php
  51. }
  52.  
  53. // Si la demande submit a été envoyé            
  54. if(isset($_POST['submit_inscription']))
  55. {
  56. /*==========================================================================\
  57. |                                                                           |
  58. |             PARTIE POUR L'ENREGISTREMENT D'UN NEW ACCOUNT                 |
  59. |                                                                           |
  60. \==========================================================================*/
  61.     echo '<div class="error-form">';
  62.     // Déclaration des variables avec la function secu
  63.     $i = 0;
  64.     $account = $_POST['account'];
  65.     $password = $_POST['password'];
  66.     $conf_password = $_POST['conf_password'];
  67.     $email = $_POST['email'];
  68.     $question = $_POST['question'];
  69.     $reponse = $_POST['reponse'];
  70.     $zero = 0;
  71.  
  72. // Condition globale
  73.     // Condition de détection si un des $_POST est vide ou pas
  74.     if(!$_POST['account'] || !$_POST['password'] || !$_POST['conf_password'] || !$_POST['email'] || !$_POST['question'] || !$_POST['reponse'])
  75.         {
  76.         echo '- Vous devez remplir tout les champs. <br />'; $i++;
  77.         }
  78.    
  79. // Conditions sur les longueurs
  80.     // Condition sur la longueur du nom de compte
  81.     if (strlen($account) > 20 || strlen($account) < 5) { echo '- Votre nom de compte doit contenir entre 5 et 20 caract&egrave;res.<br />'; $i++; }
  82.  
  83.     // Condition sur la longueur du password et la présence d'au moin un chiffre et une lettre
  84.     if (strlen($password) > 30 || strlen($password) < 6) { echo '- Votre mot de passe doit contenir au minimum des lettres et des chiffres, et doit faire entre 6 et 30 caract&egrave;res.<br />'; $i++; } 
  85.  
  86.     // Condition sur la longeur de la question
  87.     if (strlen($question) > 50 || strlen($question) < 5) {  echo '- Votre question doit contenir entre 5 et 50 caract&egrave;res. <br />'; $i++; }
  88.    
  89.     // Condition sur la longeur de la réponse
  90.     if (strlen($reponse) > 50 || strlen($reponse) < 5) { echo '- Votre r&eacute;ponse doit contenir entre 5 et 50 caract&egrave;res. <br />'; $i++; }
  91.  
  92. // Conditions sur l'égalité des deux mots de passe
  93.     // Condition pour voir si les deux mots de passe sont identiques
  94.     if ($password != $conf_password) { echo '- Les deux mots de passe ne sont pas identiques.<br />'; $i++; }
  95.    
  96. // Condition spécifique au nom de compte
  97.     // Condition sur la déjà existence du nom de compte
  98.     if(isset($_POST['account']))
  99.     {
  100.         $REQverif = $CNCTacc->prepare('SELECT COUNT( username ) AS account FROM player_accounts WHERE username = :account');
  101.         $REQverif->bindValue(':account', $account, PDO::PARAM_STR);
  102.         $REQverifr=$REQverif->execute();
  103.         $donnees2 = $REQverif->fetch();
  104.        
  105.         if($REQverifr == 1)
  106.         {
  107.            if($donnees2['account'] != 0)
  108.                   {
  109.                     echo '- Le nom de compte est d&eacute;j&agrave; utilis&eacute;.<br />'; $i++;
  110.                   }
  111.         }      
  112.         $REQverif->closeCursor();
  113.     }
  114.        
  115. // Condition si il y a une erreur
  116.     if ($i > 0)
  117.     {
  118.         if ($i == 1) { echo $i.' erreur'; }
  119.         else { echo $i.' erreurs'; }
  120.         echo '<br /><a href="#" onclick="history.go(-1);">Retourner &agrave; la page pr&eacute;c&eacute;dente</a>';
  121.     }
  122.    
  123.     else
  124.     {
  125.         $REQinscription = $CNCTacc->prepare("INSERT INTO player_accounts VALUES ('' , :account, :password, :email, :question, :reponse, '', '', '', '', 0, 0, 0, " . time() .", '')");
  126.    
  127.         /*$REQinscription->bindValue(':account', $account, PDO::PARAM_STR);
  128.         $REQinscription->bindValue(':password', MD5($password), PDO::PARAM_STR);
  129.         $REQinscription->bindValue(':email', $email, PDO::PARAM_STR);
  130.         $REQinscription->bindValue(':question', $question, PDO::PARAM_STR);
  131.         $REQinscription->bindValue(':reponse', $reponse, PDO::PARAM_STR);  
  132.         $REQinscription->bindValue(':null', '', PDO::PARAM_NULL);      
  133.         $REQinscription->bindValue(':zero', $zero, PDO::PARAM_INT);*/
  134.        
  135.         $REQinscription->execute(array('account' => $account,
  136.                                         'password' => MD5($password),
  137.                                         'email' => $email,
  138.                                         'question' => $question,
  139.                                         'reponse' => $reponse));
  140.            
  141.             echo 'Inscription réussite !<br />
  142.                     Redirection vers pa page d\'accueil en cours ...
  143.                    
  144.                     <meta http-equiv="refresh" content="2;url=?location=join" />';
  145.                
  146.         $REQinscription->closeCursor();
  147.     }
  148.     ?>
  149.     </div>
  150. <?php
  151. }
  152. ?>
  153.     </div>
  154.     <!-- Fin Inscription -->
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement