Forum Moderators: coopster
$id= tep_db_prepare_input(mysql_real_escape_string(strip_tags(htmlspecialchars($_GET['sess_id']))));
$product_id= tep_db_prepare_input(mysql_real_escape_string(strip_tags(htmlspecialchars($_POST["product_id"]))));
$email = tep_db_prepare_input(mysql_real_escape_string(strip_tags(htmlspecialchars($_POST["mail"]))));
$category_id= (int)$_POST["category_id"];
$date_time= tep_db_prepare_input(mysql_real_escape_string(strip_tags(htmlspecialchars(date('Y-m-d H:m:s')))));
Some data is validated later on, with:
$query_pull = "select * from table where
category_id='".strip_tags((int)$category_id)."' and
email='".strip_tags(addslashes($mail))."' ";
$result_query = mysql_query($query_pull) or die(mysql_error());
E.G. They set email to:
'; UPDATE table SET access = 9999999 WHERE email='myemail
I think your validation is a little excessive, the strip_tags and htmlspecialchars kinda contradict each other, don't you think? (you're not going to have any html tags after you do htmlspecialchars).
If you have magic quotes enabled, you can just do:
mysql_real_escape_string(strip_slashes($_GET['sess_id']))
If you don't have magic_quotes enabled, you can just do mysql_real_escape_string();
I never use mysql_real_escape string because I have magic_quotes enabled, and I validate anything that's not going into quotes in my query to make sure it's an integer
Have a google for "multibyte SQL \ injection".
The widely-used practice of escaping ASCII single quote "'" by turning it into "\'" is unsafe when operating in multibyte encodings that allow 0x5c (ASCII code for backslash) as the trailing byte of a multibyte character;
So as said in the mysql_real_escape_string [uk3.php.net] manual:
Escapes special characters in the unescaped_string , taking into account the current character set of the connection so that it is safe to place it in a mysql_query(). If binary data is to be inserted, this function must be used.
...
This function must always (with few exceptions) be used to make data safe before sending a query to MySQL.