Skip to content

Instantly share code, notes, and snippets.

@jovialcore
Created December 13, 2022 14:35
Show Gist options
  • Save jovialcore/9f4bdacb874e4667cb8f403458d2766c to your computer and use it in GitHub Desktop.
Save jovialcore/9f4bdacb874e4667cb8f403458d2766c to your computer and use it in GitHub Desktop.
<?php
http: //testphp.vulnweb.com/search.php?test=query
$pdo = new PDO('msql:host=vulnweb.com;dbname=vulnweb', 'dbuser', 'dbpassword');
$query = "SELECT * FROM searchabletable WHERE topic LIKE :keyword";
$stmt = $pdo->prepare($query);
$stmt->bindValue(':keyword', '%' . $variable . '%');
$stmt->execute();
// fetch results
$fetch = $statement->fetchAll(PDO::FETCH_ASSOC);
if ($fetch) {
// do something
} else {
//do something else
}
@jovialcore
Copy link
Author

Fixing a search page with sql injection

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment