Unset HTTP_POST_VARS

unset($HTTP_POST_VARS) doesn't work

How can i unset my post variables?
LVL 9
tolgaongAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

RoonaanCommented:
You can try and use:

$HTTP_POST_VARS = array();

But not sure what you mean. What do you expect to be happening after you do the unset.

Also, $HTTP_POST_VARS has been replaced with the $_POST array. $HTTP_POST_VARS still works I guess, but $_POST is prefered. Same as $_GET is preferred in favour of $HTTP_GET_VARS and there are $_SESSION and $_COOKIE and $_ENV as well.

-r-
0
tolgaongAuthor Commented:
$postarray=array("namesurname","submitnamesurname");
if (checkPosts($postarray)){
      extract($_POST);
      if ($_SESSION["fullname"]!=$namesurname){
            $db->updateSQL("update ".PREFIX.ADMINUSERS." set fullname='$namesurname' where uid=$dbuserid");
            $_SESSION["fullname"]=$namesurname;
            $HTTP_POST_VARS=array();            }
      else {
            $t->assign('message',"Girmiş olduğunuz isim önceki isminiz ile aynıdır.");
            }
      }

When I refresh the page it enters the statement again. If i could be able to unset it, It wouldn't enter the first statement(checkPosts -> my function to check posted values).  
0
ixtiCommented:
You can't unset() $HTTP_POST_VARS, because it's superglobal variable.

As said Roonaan, you can simply assign it to array()
But you have to remember that: "...$HTTP_POST_VARS contains the same initial information, but is not an autoglobal. (Note that HTTP_POST_VARS and $_POST are different variables and that PHP handles them as such)..." (c) PHP Manual.

So you can write simple function:
function cleanPostVars()
{
    if (isset($HTTP_POST_VARS)) $HTTP_POST_VARS = array();
    if (isset($_POST)) $_POST = array();
}
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.