I have created this code for testing of SQL injection.
<?php
mysql_connect('localhost', 'root', '');
mysql_select_db("test");
$id = $_POST['data'];
$query = "SELECT * FROM members WHERE memberId ='" . $id . "'";
$q = mysql_query($query);
if (mysql_num_rows($q) == 0)
{
printf("<h4>Wrong user ID!</h4>");
}
else
{
while ($row = mysql_fetch_array($q))
{
printf("<h4>Your ID is %s</h4>", $row["memberId"]);
}
}
?>
When variable $id
is 1' OR '1'='1
, I can see all IDs in the table members.
I would like also realize DROP TABLE, but I can't figure out what to insert in variable id $id
. I have tried to insert 123'; DROP TABLE sql injection--
in $id
.
Do you have any idea what to insert in $id
or how to modify this code?