PHP Parameters ( GET, POST, COOKIE )

Tired of typing $_GET["something"] or $_POST["something"] or $_COOKIE["something"]... this little functions makes that job a lot easier!

Usage is very simple just assign it do some variable.

$something = param("something"); //will search get,post and cookie
$something = param("something", "cookie"); //will search only cookie

If GET or POST or COOKIE with name "something" is set, it will definitely be in $something

function param($parametar, $force = 0){
    switch($force){
        case "get":return($_GET[$parametar]);break;
        case "post":return($_POST[$parametar]);break;
        case "cookie":return($_COOKIE[$parametar]);break;
    }
    if(!empty($_GET[$parametar])){return($_GET[$parametar]);exit;}
    if(!empty($_POST[$parametar])){return($_POST[$parametar]);exit;}
    if(!empty($_COOKIE[$parametar])){return($_COOKIE[$parametar]);exit;}
}


Remember to sanitize these variables if used in SQL queries. You can use this function http://webarto.com/55/php-mysql-injection-escape-function
©2009-2011 Webarto • web design & development • Tuzla // Sarajevo // Beograd