Guest User

Untitled

a guest
Jun 17th, 2018
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.35 KB | None | 0 0
  1. <?php
  2. include("db.php");
  3.  
  4. if (isset($_POST['username']) &&
  5. isset($_POST['password']) &&
  6. isset($_POST['email']))
  7. {
  8. //Prevent SQL injections
  9. $username = mysql_real_escape_string($_POST['username']);
  10. $email = mysql_real_escape_string($_POST['email']);
  11.  
  12. //Get MD5 hash of password
  13. $password = md5($_POST['password']);
  14.  
  15. //Check to see if username exists
  16. $sql = mysql_query("SELECT username FROM usersystem WHERE username = 'username'");
  17.  
  18. if (mysql_num_rows($s > 0))
  19. {
  20. die ("Username taken.");
  21. }
  22.  
  23. mysql_query("INSERT INTO usersystem (username, password, email) VALUES ( '$username', '$password', '$email')")
  24. or die (mysql_error()); echo "Account created.";
  25. }
  26. ?>
  27.  
  28. <?php
  29. session_start();
  30. mysql_connect("localhost", "mydatabase", "mypassword");
  31. mysql_select_db("ratherda_jetpackfandango");
  32.  
  33. function user_login ($username, $password)
  34. {
  35. //take the username and prevent SQL injections
  36. //$username = mysql_real_escape_string($username);
  37.  
  38. //begin the query
  39. $sql = mysql_query("SELECT * FROM user WHERE username = 'username' AND password = 'password' LIMIT 1");
  40.  
  41. //check to see how many rows were returned
  42. $rows = mysql_num_rows($sql);
  43.  
  44. if ($rows<=0 )
  45. {
  46. echo "Incorrect username/password";
  47. }
  48. else
  49. {
  50. //have them logged in
  51. $_SESSION['username'] = $username;
  52. }
  53. }
  54. ?>
  55.  
  56. <?php
  57.  
  58. session_start();
  59.  
  60. require_once("db.php");
Add Comment
Please, Sign In to add comment