SHARE
TWEET

Untitled

a guest Jun 8th, 2017 66 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <html>
  2. <body>
  3.  
  4.     <?php
  5.         mysql_connect('localhost', 'root', '');
  6.         mysql_select_db('membership');
  7.        
  8.        
  9.         if (isset($_POST['submit']))
  10.         {
  11.             $username = $_POST['user'];
  12.             $password = md5($_POST['pass']);
  13.        
  14.             $query = mysql_query("SELECT * FROM users WHERE username = '" . $username . "'");
  15.             if (mysql_num_rows($query) == 0)
  16.             {
  17.                 echo 'Success';
  18.                
  19.                 $insert = mysql_query("INSERT INTO users (username, password) VALUES('$username', '$password')");
  20.             }
  21.             else
  22.             {
  23.                 echo 'Username already taken';
  24.                 echo '<br><a href="register.php">Go Back</a>';
  25.             }
  26.         }
  27.         else
  28.         {
  29.        
  30.     ?>
  31.  
  32.  
  33.     <form method="POST">
  34.     <label for="user">Username:</label>
  35.     <input type="text" name="user" /><br />
  36.     <label for="pass">Password:</label>
  37.     <input type="text" name="pass" size="5" /><br />
  38.     <input type="submit" name="submit" value="Submit" />
  39.     </form>
  40.    
  41.    
  42.  
  43.     <?php
  44.         }
  45.     ?>
  46.    
  47. </body>
  48. </html>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top