/ Published in: PHP
This is a simple function that sanitizes the data before sending it to MySQL. First it removes whitespaces from the beginning and ending of the string. If magic_quotes_gpc is enabled and the data has been already escaped we will apply stripslashes() to the data. This way the data won’t be escaped twice when mysql_real_escape_string() is called.
Example:
$username = sanitize($_POST['username']);
$password = sanitize($_POST['password']);
Example:
$username = sanitize($_POST['username']);
$password = sanitize($_POST['password']);