Easier way to clean GET Variables ?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Is there a way to loop thru all of these GET requests by:
putting the GET variables into an array
processing  the variable strings with trim/striptags/etc in a loop
exploding the variables back out into separate variables

otherwise this gets a bit tedious :(

many thanks in advance
g


$userID = $_GET['userID'];
$playlistName = $_GET['playlistName'];
$language = $_GET['language'];
$query = $_GET['query'];
$mediaID = $_GET['mediaID'];


# did we get $userID in a GET request ?
if(!isset($userID)){
	# add a default query here
	$userID = "unknown" ;
}
# did we get $playlistName in a GET request ?
if(!isset($playlistName)){
	# add a default query here
	$playlistName = "Unknown" ;
}
# did we get $language in a GET request ?
if(!isset($language)){
	# add a default language here
	$language = "spanish" ;
}
# did we get $query in a GET request ?
if(!isset($query)){
	$query = "unknown" ;
}
# did we get $mediaID in a GET request ?
if(!isset($mediaID)){
	# add a default query here
	$mediaID = "unknown" ;
}
$userID = trim(strip_tags($userID));
$playlistName = trim(strip_tags($playlistName));
$language = trim(strip_tags($language));
$query = trim(strip_tags($query));
$mediaID = trim(strip_tags($mediaID));

mysql_real_escape_string($userID);
mysql_real_escape_string($playlistName);
mysql_real_escape_string($language);
mysql_real_escape_string($query);
mysql_real_escape_string($mediaID);

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux