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();
}
}
Code: Select all
pt_register('POST','key_word');
if ($_SERVER['REQUEST_METHOD'] != 'POST'){
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?