Guest User

Untitled

a guest
Oct 26th, 2017
198
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.30 KB | None | 0 0
  1. <?php
  2.  
  3. echo "<h1>Register</h1>";
  4.  
  5. $submit = ($_POST['submit']);
  6.  
  7. $fullname = strip_tags($_POST['fullname']);
  8. $username = strip_tags($_POST['username']);
  9.  
  10. $password = strip_tags($_POST['password']);
  11. $repeatpassword = strip_tags($_POST['repeatpassword']);
  12.  
  13. $date = ('Y-m-d');
  14.  
  15. if ($submit) {
  16.  
  17.     // Check to see if they are in database already
  18.     if($fullname&&$username&&$password&&$repeatpassword) {
  19.        
  20.         if ($password==$repeatpassword) {
  21.  
  22.             // check char lenght of username and fullname
  23.             if (strlen($username)>25||strlen($fullname)>25)
  24.                 {
  25.                     echo "Full name or Username is too long!";
  26.                 }
  27.                 else
  28.                 {
  29.                     // check lenght of password
  30.                     if (strlen($password)>25||strlen($password)<6)
  31.                     {
  32.                         echo "Password <strong>Must</strong> be between 6 and 25 characters";
  33.                        
  34.                     }
  35.                     else {
  36.                     // Register Users
  37.                    
  38.                       echo "Success";
  39.                      
  40.                       $password = md5($password);
  41.                       $repeatpassword = md5($repeatpassword);
  42.                      
  43.                       // Open Database
  44.                       $connect = mysql_connect("localhost","root","");
  45.                       mysql_select_db("hub");
  46.                      
  47.                       // Generator random number, for activation.
  48.                      
  49.                       $random = rand(23456789,98765432);
  50.                      
  51.                       $queryreg = mysql_query("
  52.                      
  53.                       INSERT INTO users VALUES ('','$fullname','$username','$password','$date','$random','0')
  54.                      
  55.                       ");
  56.                      
  57.                       die("Well done, Your account have been created, return to <a href='index.php'>login</a>");
  58.                    
  59.                     }
  60.                    
  61.                 }
  62.         }
  63.         else
  64.             echo "Your password don't match!";
  65.     }
  66.     else
  67.         echo "Please fill in <strong>all</strong> fields.";
  68. }
  69.  
  70. ?>
  71.  
  72. <!DOCTYPE html>
  73. <html lang="">
  74. <head>
  75.   <meta charset="utf-8">
  76.     <title></title>
  77.     <meta name="description" content="" />  
  78.     <meta name="keywords" content="" />
  79.     <meta name="robots" content="" />
  80. </head>
  81. <body>
  82.  
  83.     <form action='register.php' method='post'>
  84.         <label>Full Name</label><input type='text' name='fullname' value='<?php echo $fullname; ?>'>
  85.         <label>Choose Username</label><input type='text' name='username' value='<?php echo $username; ?>'>
  86.         <label>Choose Password</label><input type='password' name='password'>
  87.         <label>Repeat Password</label><input type='password' name='repeatpassword'>
  88.         <input type='submit' name='submit' value='Register'>
  89.     </form>
  90.  
  91. </body>
  92. </html>
Add Comment
Please, Sign In to add comment