Return to Snippet

Revision: 9280
at October 28, 2008 05:58 by alli14404


Initial Code
function clean($var){
    
    	return (get_magic_quotes_gpc()) ? stripslashes(mysql_real_escape_string($var)) : mysql_real_escape_string($var) ;
    
    }

	function grab_postvar($index, $clean = true){
    
    	return (isset($_POST[$index]) && !empty($index)) ? (($clean) ? clean($_POST[$index]) : $_POST[$index] ) : false ;
    
    }
	
	/* Usage: $post_variable = grab_postvar("id"); | Returns the variable else returns boolean false */
	
    
    function grab_getvar($index, $clean = true){
    
    	return (isset($_GET[$index]) && !empty($index)) ? (($clean) ? clean($_GET[$index]) : $_GET[$index] ) : false ;
    
    }
	
	/* Usage: $get_variable = grab_getvar("id"); | Returns the variable else returns boolean false */
	
	
	function grab_referer($default = NULL){
	
		return (isset($_SERVER['HTTP_REFERER']) && !empty($_SERVER['HTTP_REFERER'])) ? clean($_SERVER['HTTP_REFERER']) : ((is_null($default)) ? '/' : $default ) ;
	
	}
	
	/* Usage: $referer_url = grab_referer("index.php"); */

Initial URL

                                

Initial Description
This set of functions makes it quicker for me to code, might be useful to someone else =]

Initial Title
Clean & Grab POST/GET/Referer Variable functions

Initial Tags
post

Initial Language
PHP