Page 1 of 1

I Need to update outdated method

Posted: Tue Jul 20, 2010 2:57 pm
by someguyhere
I am using the following code in a form:

Code: Select all

function pt_register(){

  $num_args = func_num_args();
   $vars = array();

   if ($num_args >= 2) {
       $method = strtoupper(func_get_arg(0));

       if (($method != 'SESSION') && ($method != 'GET') && ($method != 'POST') && ($method != 'SERVER') && ($method != 'COOKIE') && ($method != 'ENV')) {
           die('The first argument of pt_register must be one of the following: GET, POST, SESSION, SERVER, COOKIE, or ENV');
     }

       $varname = "HTTP_{$method}_VARS";
      global ${$varname};

       for ($i = 1; $i < $num_args; $i++) {
           $parameter = func_get_arg($i);

           if (isset(${$varname}[$parameter])) {
               global $$parameter;
               $$parameter = ${$varname}[$parameter];
          }

       }

   } else {
       die();
   }

}
and then a bit later, this:

Code: Select all

pt_register('POST','key_word');

   if ($_SERVER['REQUEST_METHOD'] != 'POST'){

Followed by a bunch of other stuff (php & html).

Basically, I have a page that contains a form. When you fill in the field and hit submit, it processes the data and then presents some info on the same page. I was doing a bit of research to fix another issue (I need the script not to pass header info since it's part of a plugin for Wordpress) and found that this method is outdated. Can someone point me to a better method?

Re: I Need to update outdated method

Posted: Tue Jul 20, 2010 3:47 pm
by Weirdan
Why do you need anything from request/environment in the global scope?