Advertisement
Guest User

Untitled

a guest
Aug 16th, 2017
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.45 KB | None | 0 0
  1. <?php
  2.  
  3.  
  4.  
  5. $bdd = new PDO('mysql:host=127.0.0.1;dbname=dx-weather', 'root', '');
  6.  
  7. if(isset($_POST['registerform']))
  8. {
  9.         $username = htmlspecialchars($_POST['username']);
  10.         $email = htmlspecialchars($_POST['email']);
  11.         $confirmemail = htmlspecialchars($_POST['confirmemail']);
  12.         $password = sha1($_POST['password']);
  13.         $confirmpassword = sha1($_POST['confirmpassword']);
  14.  
  15.   if(!empty($_POST['username']) AND $_POST['email'] AND $_POST['confirmemail'] AND $_POST['password'] AND $_POST['confirmpassword'])
  16.     {
  17.        
  18.  
  19.         $usernamelength = strlen($username);
  20.         if($usernamelength <= 255)
  21.             {
  22.                     if($email == $confirmemail)
  23.                     {
  24.  
  25.                         if(filter_var($email, FILTER_VALIDATE_EMAIL))
  26.                         {
  27.  
  28.                
  29.  
  30.                         if($password == $confirmpassword)
  31.                         {
  32.                             $insertuser = $bdd->prepare("INSERT INTO user(username, mail, password) VALUES(?, ?, ?)");
  33.                             $insertuser->execute(array($username, $email, $password));
  34.                             $erreur = "Votre compte a bien été crée";
  35.                         }
  36.                         else
  37.                         {
  38.                             $erreur = "Vos mot de passes ne correspondent pas";
  39.                         }
  40.  
  41.  
  42.                     }
  43.                     else
  44.                     {
  45.  
  46.                         $erreur = "Votre adresse mail n'est pas valide!";
  47.                     }
  48.  
  49.  
  50.                     }
  51.                     else
  52.                     {
  53.                         $erreur = "Vos adresses emails ne correspondent pas !";
  54.                     }
  55.                    
  56.                 }
  57.                 else
  58.                 {
  59.                     $erreur = "Votre pseudo ne doit pas dépasser 255 caractères !";
  60.                 }
  61.  
  62.  
  63.  
  64.     }
  65.  
  66.         else
  67.     {
  68.         $erreur = "Tous les champs doivent être complétés !";
  69.     }
  70.  
  71. }
  72.  
  73. ?>
  74.  
  75. <html>
  76.     <head>
  77.         <title>Registe</title>
  78.         <meta charset="utf-8">
  79.     </head>
  80.     <body>
  81.         <div align="center">
  82.         <h2>Register</h2>
  83.         <br /><br /><br />
  84.         <form method="POST" action="">
  85.  
  86.  
  87.         <input type="text" placeholder="username" name="username" value="<?php if(isset($username)) { echo $username; } ?>"> <br /><br />
  88.         <input type="email" placeholder="email" name="email" value="<?php if(isset($email)) { echo $email; } ?>">  <br /><br />
  89.         <input type="email" placeholder="confirm memail" name="confirmemail" value="<?php if(isset($confirmemail)) { echo $confirmemail; } ?>">  <br /><br />
  90.         <input type="password" placeholder="password" name="password">  <br /><br />
  91.         <input type="password" placeholder="confirm password" name="confirmpassword"> <br /><br />
  92.         <input type="submit" value="Confirm Registration" name="registerform">
  93.  
  94.  
  95.  
  96.  
  97.         </form>
  98.  
  99. <?php
  100.  
  101. if(isset($erreur))
  102. {
  103.     echo '<font color="red">' .$erreur. '</font>';
  104. }
  105.  
  106. ?>
  107.  
  108.         </div>
  109.  
  110.  
  111.  
  112.  
  113.     </body>
  114.  
  115. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement