I have a form that sends an array of transaction IDs to $_POST['transid'] so that these transaction records can be deleted.
I usually use mysqli_real_escape_string to prevent attacks, but I'm not sure how to do this with an array. Below is my request:
 $query = 'DELETE FROM TRANSACTIONS WHERE (transid) IN ("'.implode('","',$_POST[transid]).'")' 
... which gives me something like this:
 $query = 'DELETE FROM TRANSACTIONS WHERE (transid) IN ("123","124","138","145")' 
This seems to be in trouble. How can I protect myself from disaster (malicious or otherwise)? Is there an effective way to sanitize an array? Or should I go this other way?
Any thoughts or recommendations would be appreciated.
source share