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