Jump to content

SQL injection and XSS attack on checkbox


angelali

Recommended Posts

Well, I just want to know, if I add mysql_real_escape_string and strip_tags to a checkbox, does this mean it is 100% protected from SQL injection and XSS attack? For example:

 

<input type=checkbox' name="checkbox"/>

$checkbox = mysql_real_escape_string(stip_tags($_POST['checkbox']));

Jesirose knows this code as she was helping me yesterday.... By the way Jesirose, I successfully solved the problem yesterday.. Here are the codes what Im telling you below:

 

The checkbox:

 

echo '<td><input type="checkbox" name="delete[]" value="'.$row['img_ID'].'"/></td>';

 

A part of the codes:

if (isset($_POST['delete'])) {
foreach ($_POST['delete'] as $delete)
{
$ids[] = mysql_real_escape_string(strip_tags($delete));
}
mysql_query("DELETE FROM photos WHERE images_ID IN (".implode(',',$ids).")");;
echo "Record Deleted.";
}

 

 

Everything is ok, only want to know if this can be attacked thats all..

Again, if you're expecting an integer, just cast it as an integer. You don't need to do anything else with it.

 

By the way, this is not help on demand. Not getting a reply within 20 minutes is not a reason to bump the thread. Most of us have jobs and families, and I am caring for my 6 month old son while working. The rule on this forum is no bumping threads.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.