Page 2 of 2

Posted: Wed Oct 11, 2006 10:17 am
by RobertGonzalez
dibyendrah wrote:Inside the function, unless you pass the variable as argument, other variable cannot be accessed unless you call global variable. So, you better call the global POST, GET variable by writing the statement :

Code: Select all

global $HTTP_POST_VARS;
will solve your problem.

Code: Select all

function validateInput(){
    global $HTTP_POST_VARS;
    if(empty($HTTP_POST_VARS['fname'])){
        return false;
    }else{
        return true;
    }
}
With Regards,
Dibyendra
Long arrays are deprecated. In PHP3 and PHP4, if you wanted to use them inside a function you had to gloablize them, but in in PHP4 and PHP5 the short arrays are super globals and do not need to be globalized (as they are already gloabl). So in a nutshell:
  • Use $_GET not $HTTP_GET_VARS
  • Use $_POST not $HTTP_POST_VARS
  • Use $_COOKIE not $HTTP_COOKIE_VARS
  • Use $_SESSION not $HTTP_SESSION_VARS
  • Use $_SERVER not $HTTP_SERVER_VARS
  • Use $_ENV not $HTTP_ENV_VARS

Posted: Thu Oct 12, 2006 2:38 am
by dibyendrah
Thanks for the information. It has been a habit doing in the same old style.

Regards,
Dibyendra