Return to Snippet

Revision: 22233
at January 6, 2010 15:57 by jdmyers


Initial Code
################################################################
#
#	Data Cleaning Function
#		- helps prevent MySQL injection, use when building the query after database connecton established
#		- Original Source: http://www.digital-web.com/articles/bulletproof_contact_form_with_php/
#		- trim function added by me
#
################################################################
function cleanData($string)
{
	if (get_magic_quotes_gpc())
	{
		// strip slashes if mahic quotes are on
		$string = stripslashes($string);
	}
	// remove unwanted HTML (not allowed)
	$string = strip_tags($string);
	// trim any leading and trailing whitespace
	$string = trim($string);
	// return the string with escaping slashes
	return mysql_real_escape_string($string);
}

Initial URL
php

Initial Description

                                

Initial Title
Data Cleaning Function

Initial Tags

                                

Initial Language
PHP