Advertisement
Guest User

Untitled

a guest
Jul 11th, 2017
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.83 KB | None | 0 0
  1. <?php
  2.  
  3. session_start();
  4.  
  5. $username = $_POST['username'];
  6. $password = $_POST['password'];
  7.  
  8. if ($username && $password)
  9. {
  10. $connect = mysql_connect("localhost", "root", "") or die("Couldn't connect!");
  11. mysql_select_db("phplogin") or die("Couldn't find the database");
  12.  
  13. $query = mysql_query("SELECT * FROM users WHERE username='$username'");
  14.  
  15. $numrows = mysql_num_rows($query);
  16. if ($numrows != 0)
  17. {
  18. while ($row = mysql_fetch_assoc($query))
  19. {
  20. $dbusername = $row['username'];
  21. $dbpassword = $row['password'];
  22. }
  23. if ($dbusername == $username && $password == $dbpassword)
  24. {
  25. echo "You're in! <a href='homepage.html'> Click</a> here to enter the homepage.";
  26. $_SESSION['username'] = $dbusername;
  27. }
  28. else
  29.     die("Incorrect password!");
  30. }
  31. else
  32.     die("User does not exist!");
  33.    
  34.  
  35. }
  36. else
  37.     die("Please enter a username and password.");
  38. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement