Advertisement
Guest User

Untitled

a guest
Jun 11th, 2017
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.96 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.  
  8.     if((!empty($_POST['username']) && !empty($_POST['password'] != "")) && $_POST['password'] == $_POST['vpassword']) {
  9.         $query;
  10.         if($query) {
  11.             session_start();
  12.             $_SESSION['user'] = $username;
  13.             if (isset($_SESSION['user'])) {
  14.                 header("Location: index.php");
  15.             }
  16.         } else {
  17.             echo "Failed to register";
  18.         }
  19.     } else {
  20.         if($_POST['password'] != $_POST['vpassword']) {
  21.             echo "Your passwords do not match! <br /><br />";
  22.         }
  23.     }
  24. ?>
  25.  
  26. <html>
  27.     <body>
  28.         <form action='register.php' method='post'>
  29.             Username: <input type='text' name='username' /><br />
  30.             Password: <input type='password' name='password' /><br />
  31.             Verify Password: <input type='password' name='vpassword' /> <br />
  32.             <input type='submit' value='register' />
  33.         </form>
  34.     </body>
  35. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement