Advertisement
Guest User

Untitled

a guest
Dec 20th, 2017
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.93 KB | None | 0 0
  1. <?php
  2.  
  3. $servername = "localhost";
  4. $username = "pi";
  5. $password = "raspberry";
  6. $dbname = "sql_injections";
  7.  
  8. //Create a connection
  9. $conn = new mysqli($servername, $username, $password, $dbname);
  10.  
  11. //Check the connection
  12. if ($conn->connect_error)
  13. {
  14. die ("Connection failed!");
  15. }
  16.  
  17. try
  18. {
  19. $check_login_credentials = $conn->query("SELECT * FROM accounts WHERE Username='".$_POST[username]."' AND Password='".$_POST[password]."';");
  20. }
  21.  
  22. catch (Exception $login_data_exception)
  23. {
  24. echo "[!] Error: ".$login_data_exception->getMessage()."\n";
  25. }
  26.  
  27. if (!$check_login_credentials)
  28. {
  29. echo "[!] Wrong credentials! ";
  30. echo "Username: ".$_POST[username]." Password: ".$_POST[password];
  31. }
  32.  
  33. else
  34. {
  35. echo "[+] You are now logged in. The provided credentials have been found in our database!";
  36. }
  37.  
  38. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement