If your project is accepting user input and you’re using MySQL, you’ll probably want to take a look at data sanitation. Luckily for you, I have a really useful function that takes your user’s input and sanitizes it so that it’s safe for database use.
The function:
function safedata($original) {
return mysql_real_escape_string(stripslashes(strip_tags(
htmlspecialchars(trim($original)))));
}
return mysql_real_escape_string(stripslashes(strip_tags(
htmlspecialchars(trim($original)))));
}
How to use the function:
$username = safedata($_POST[‘username’]); // That’s all you need!
Please note that in order for this function to work properly, you’ll need to be connected to a database.