Return to Snippet

Revision: 4281
at November 21, 2007 14:35 by peteypablonz


Updated Code
<?php

function clean($value)
{
	if (get_magic_quotes_gpc())	$value = stripslashes($value);
	
	if (!is_numeric($value))	$value = mysql_real_escape_string($value);
	
	return $value;
}

array_walk($_GET,'clean');
array_walk($_POST,'clean');
array_walk($_COOKIE,'clean');

extract($_GET,EXTR_PREFIX_ALL,'get');
extract($_POST,EXTR_PREFIX_ALL,'post');
extract($_COOKIE,EXTR_PREFIX_ALL,'cookie');

?>

Revision: 4280
at November 21, 2007 03:57 by peteypablonz


Initial Code
<?php

function clean($value)
{
	if (get_magic_quotes_gpc())	$value = stripslashes($value);
	
	if (!is_numeric($value))	$value = mysql_real_escape_string($value);
	
	return $value;
}

array_walk($_GET,'clean');
array_walk($_POST,'clean');
array_walk($_COOKIE,'clean');

extract($_GET,EXTR_PREFIX_ALL,'get');
extract($_POST,EXTR_PREFIX_ALL,'post');
extract($_COOKIE,EXTR_PREFIX_ALL,'post');

?>

Initial URL
http://www.meelsonwheels.com

Initial Description
Created for my own purposes, thought I'd share though ;)

copy paste at the top of your file and it does the magic :)

Initial Title
clean user input data ( GET, POST, COOKIE )

Initial Tags
mysql, sql, php, post

Initial Language
PHP