Guest User

Untitled

a guest
Nov 1st, 2017
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.14 KB | None | 0 0
  1. <?php
  2.  
  3. session_start();
  4.  
  5. include 'forum/connect.php';
  6.  
  7. $username = $_POST['username'];
  8. $password = $_POST['password'];
  9.  
  10.  
  11. if ($username && $password)
  12. {
  13.  
  14. $sql = "SELECT * FROM users WHERE username='$username'";
  15. $query = mysqli_query($link, $sql);
  16.  
  17. $numrows = mysqli_num_rows($query);
  18.  
  19. echo 'num rows: ' . $numrows . ' mysql_error . ' . mysqli_error($link); die();
  20.  
  21. if ($numrows!=0)
  22. {
  23. while ($row = mysqli_fetch_assoc($query))
  24. {
  25. $dbusername = $row['username'];
  26. $dbpassword = $row['password'];
  27. }
  28.  
  29. // Check to see if they match!
  30. if ($username==$dbusername&&md5 ($password==$dbpassword))
  31. {
  32. echo 'Successfully Logged in! <a href="member.php">Click here to enter the member page!</a>';
  33. $_SESSION['username']=$username;
  34. $_SESSION['id'] = $row['id'];
  35. $_SESSION['username'] = $row['username'];
  36. $_SESSION['password'] = $row['password'];
  37. $_SESSION['email'] = $row['email'];
  38. }
  39.  
  40. else
  41. {
  42. echo "Incorrect Password!";
  43. }
  44. }
  45. else
  46. die("That user does not exist!");
  47.  
  48. }
  49.  
  50. else
  51. die("Please enter a username and a password");
  52.  
  53.  
  54. include ("index.htm");
  55.  
  56. ?>
Add Comment
Please, Sign In to add comment