Advertisement
Guest User

Untitled

a guest
Jun 11th, 2017
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.15 KB | None | 0 0
  1. <?php
  2.  
  3.     require ('settings/connect.php');
  4.  
  5.     $query = mysql_query("INSERT INTO users (username, password) VALUES ('$_POST[username]', 'sha1($_POST[password])')");
  6.     $username = $_POST['username'];
  7.     $checkpass = strlen($_POST['password']);
  8.  
  9.     if((!empty($_POST['username']) && !empty($_POST['password'])) && $_POST['password'] == $_POST['vpassword']) {
  10.         if($checkpass >= 5 && $checkpass <= 20) {
  11.             if($query) {
  12.                 session_start();
  13.                 $_SESSION['user'] = $username;
  14.                    
  15.                 if (isset($_SESSION['user'])) {
  16.                     header("Location: index.php");
  17.                 }
  18.             } else {
  19.                 echo "Failed to register" . mysql_error();
  20.             }
  21.         } else {
  22.             echo "Your username is either too short or too long, try again";
  23.         }
  24.     } else {
  25.         if($_POST['password'] != $_POST['vpassword']) {
  26.             echo "Your passwords do not match! <br /><br />";
  27.         }
  28.     }
  29. ?>
  30.  
  31. <html>
  32.     <body>
  33.         <form action='register.php' method='post'>
  34.             Username: <input type='text' name='username' /><br />
  35.             Password: <input type='password' name='password' /><br />
  36.             Verify Password: <input type='password' name='vpassword' /> <br />
  37.             <input type='submit' value='register' />
  38.         </form>
  39.     </body>
  40. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement