Advertisement
Guest User

Untitled

a guest
Jun 8th, 2017
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.91 KB | None | 0 0
  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>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement