Return to Snippet

Revision: 47592
at June 10, 2011 22:57 by nebojsac


Initial Code
function sanitize($data)
{
	$data = trim($data); 
	if(get_magic_quotes_gpc())
	{
		$data = stripslashes($data);
	}
	$data = mysql_real_escape_string($data);
	return $data;
}

//example
$username = sanitize($_POST['username']);

Initial URL
tricksbycinger.blogspot.com

Initial Description
The function returns the "sanitized" version of user input. Use before putting variables into SQL code.

Initial Title
Sanitize user input PHP

Initial Tags
mysql, php, function

Initial Language
PHP