Possible Duplicate:
What's the best method for sanitizing user input with PHP?
What are the best PHP input sanitizing functions?
The ultimate clean/secure function
Goal: Properly sanitize all inputs from text boxes before entering into DB, which is then output to a page. For my use case, I need to prevent potential problems while not eliminating the data input. Also, the charset is explicitly set to UTF-8 in both the HTTP header and the META tag to prevent problems with malformed encoding. The DB is also set to UTF-8.
Specs: PHP, MySQL, Apache
Sample Code:
function secureinput($input)
{
$input = htmlspecialchars($input, ENT_QUOTES ,'UTF-8');
$input = strip_tags($input); //fail-safe for anything that gets through
$input = mysql_real_escape_string($input);
return $input;
}
Question: What vectors of attack (XSS, SQL Injection, etc.) is this still vulnerable to?
A huge thanks to anyone who can help. This is my first time posting, though I've always turned to SO first for looking up answers to my questions. Unfortunately, this time I couldn't find any other questions that answered my problem, only small parts of it.