Guest User

Untitled

a guest
Oct 29th, 2017
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.16 KB | None | 0 0
  1. <?php
  2. $connection = mysqli_connect(
  3. "localhost",
  4. "root",
  5. "",
  6. "mydb"
  7. );
  8.  
  9. if (mysqli_connect_errno()) {
  10. exit('failed to connect to the database server.');
  11. }
  12.  
  13. if (!isset($_GET['auth_username']) || !isset($_GET['auth_password'])) {
  14. exit('you failed to provide the correct parameters.');
  15. }
  16.  
  17. $username = isset($_GET['auth_username']) ? $_GET['auth_username'] : '';
  18. $password = isset($_GET['auth_password']) ? $_GET['auth_password'] : '';
  19.  
  20. $commandText = "SELECT `password`,`has_subscription` FROM `a__client_accounts`";
  21. $whereClause = "WHERE `username` = '" . $username . "'";
  22. $result = $connection->query($commandText . " " . $whereClause);
  23.  
  24. if (!$result) {
  25. exit('Invalid query: ' . $connection->error);
  26. }
  27. else if ($result->num_rows > 0) {
  28. $array = $result->fetch_array();
  29.  
  30. if (!password_verify($password, $array['password'])) {
  31. exit('we found your account, but you entered the wrong password.');
  32. }
  33. else if ($array['has_subscription'] == '0') {
  34. exit('you authenticated, but you don't have a subscription');
  35. }
  36. else {
  37. exit('congratulations');
  38. }
  39. }
  40. else {
  41. echo 'no account was found with that name.';
  42. }
Add Comment
Please, Sign In to add comment