Guest User

Untitled

a guest
Oct 9th, 2018
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.53 KB | None | 0 0
  1. <?php
  2.  
  3. $user = 'root';
  4. $password = 'root';
  5. $db = 'SQL-Injection';
  6. $host = 'localhost';
  7. $port = 3306;
  8.  
  9. $link = mysql_connect(
  10. "$host:$port",
  11. $user,
  12. $password
  13. );
  14. $db_selected = mysql_select_db(
  15. $db,
  16. $link
  17. );
  18.  
  19. // dynamically build the sql statement with the input
  20. $query = "SELECT COUNT(user_id) FROM cars WHERE car_name = '$_GET[car_name]'";
  21.  
  22. // execute the query against the database
  23. $result = mysql_fetch_row(mysql_query($query));
  24.  
  25. if ($result[0]) {
  26. print_r($result[0] . ' cars');
  27. } else {
  28. print_r('Nothing to show');
  29. }
Add Comment
Please, Sign In to add comment