Twitsnip is a place to post code snippets and share them. Login with your existing Twitter account, if you don't have a Twitter account simply create on at www.twitter.com

Function to clean POST variables

Function to clean POST variables

0

This functions allows you to filter any post data ready for insertion into MySQL

// This function is used to clean POST variables.	
function clean($value) {

	// If magic quotes not turned on add slashes.
	if(!get_magic_quotes_gpc())
	
	// Adds the slashes.
	{ $value = addslashes($value); }
	
	// Strip any tags from the value.
	$value = strip_tags($value);
	
	// Return the value out of the function.
	return $value;
	
} // End function.

//usage simple pass a string to the function and return the data back to the same variable

$sample = "<a href='#'>test</a>";

$sample = clean($sample);

echo $sample;

Tags: post, data, clean, get_magic_quotes_gpc, addslashes, strip_tags, function

Comments

No comments yet

Login to Twitter to comment