Advertisement
Guest User

Untitled

a guest
Feb 15th, 2018
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.91 KB | None | 0 0
  1. <!DOCTYPE HTML>
  2. <html>
  3. <?php
  4. session_start();
  5. include_once "header.php"
  6. ?>
  7.  
  8.     <head>
  9.    
  10.         <link href="https://fonts.googleapis.com/css?family=Roboto" rel="stylesheet">
  11.         <link href="/css/index.css" rel="stylesheet">
  12.         <meta charset="UTF-8">
  13.        
  14.        
  15.         <title><?php echo htmlspecialchars($site_name); echo " &ndash; Register"; ?></title>
  16.     </head>
  17.    
  18.     <body style="background-color:#111111;">
  19.         <?php
  20.            
  21.             function addUser($username, $password, $email, $connn){
  22.                 $password_safe = password_hash($password, PASSWORD_BCRYPT);
  23.                
  24.                 $sql = "INSERT INTO user (username, password, email) VALUES ('$username', '$password_safe', '$email')";
  25.                 $result = mysqli_query($connn, $sql);
  26.                 echo($conn);
  27.                
  28.             }
  29.        
  30.        
  31.             $username = $_POST["username"];
  32.             $password = $_POST["password"];
  33.             $password2 = $_POST["passwordagain"];
  34.             $email = $_POST["email"];
  35.             $success = array(
  36.                 "success" => True,
  37.                 "username" => True,
  38.                 "password" => True,
  39.                 "passwordagain" => True,
  40.                 "email" => True,
  41.                 "exists" => True,
  42.                 "exists_username" => True,
  43.                 "exists_email" => True,
  44.                
  45.             );
  46.  
  47.             if(isset($_POST["username"], $_POST["password"], $_POST["passwordagain"], $_POST["email"])){
  48.                 if(strlen($username) < 4){
  49.                     $success["username"] = False;
  50.                     $success["success"] = False;
  51.                 }else if(strlen($password) < 8){
  52.                     $success["password"] = False;
  53.                     $success["success"] = False;
  54.                 }else if(!preg_match('/[A-Za-z].*[0-9]|[0-9].*[A-Za-z]/', $password)){
  55.                     $success["password"] = False;
  56.                     $success["success"] = False;
  57.                 }else if(!strpos($email, "@") || !strpos($email, ".")){
  58.                     $success["email"] = False;
  59.                     $success["success"] = False;
  60.                 }else if($password != $password2){
  61.                     $sucess["passwordagain"] = False;
  62.                     $success["success"] = False;   
  63.                 }
  64.                
  65.                 if($success["success"] == True){
  66.                     $username_safe = mysqli_real_escape_string($conn, $username);
  67.                     $password_safe = mysqli_real_escape_string($conn, $password2);
  68.                     $email_safe = mysqli_real_escape_string($conn, $email);
  69.                     $sql_un = "SELECT $username_safe FROM user";
  70.                     $result_un = mysqli_query($conn, $sql_un);
  71.                     if ($result_un->num_rows > 0) {
  72.                         $success["exists"] = False;
  73.                         $success["success"] = False;
  74.                     } else {
  75.                         $sql_mail = "SELECT $email_safe FROM user";
  76.                         $result_mail = mysqli_query($conn, $sql_mail);
  77.                         if ($result_mail->num_rows > 0) {
  78.                             $success["exists"] = False;
  79.                             $success["success"] = False;
  80.                         } else {
  81.                             //Finally register user
  82.                             addUser($username_safe, $password_safe, $email_safe, $conn);
  83.                         }
  84.                     }
  85.  
  86.                 }else{
  87.                     //TO-DO///////////LVL3///////////Redirect user back to register page with information about failure
  88.                 }
  89.                
  90.             }else{
  91.                 //TO-DO///////////LVL3///////////Redirect user back to register page with information about failure
  92.             }
  93.         ?>
  94.         <div align="center">
  95.  
  96.         <font color="white"><p tkey="registerheader"></p></font>
  97.         <form action="/register.php" method="post">
  98.           <span><font color="white"><a tkey="registername"></a>: <input type="text" name="username" placeholder="Username"></font></span>
  99.              <br>
  100.               <span><font color="white"><a tkey="registerpassword"></a>: <input type="password" name="password" placeholder="Password"></font></span>
  101.              <br>
  102.              <span><font color="white"><a tkey="registerpasswordagain"></a>: <input type="password" name="passwordagain" placeholder="Password Again"></font></span>
  103.              <br>
  104.              <span><font color="white"><a tkey="registermail"></a>: <input type="text" name="email" placeholder="A-mail adress"></font></span>
  105.              <br>
  106.          
  107.          <i><font color="white"><a class="nodeco" href="http://teez0sproject.my-style.in/login" tkey="login"></a></font></i><br>
  108.           <input type="submit" tkey="loginsend" class="btn">
  109.         </form>
  110.         </div>
  111.            
  112.             <script src="http://code.jquery.com/jquery-1.11.0.min.js"></script>
  113.             <script src="js/lang.js"></script>
  114.     </body>
  115.    
  116. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement