[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Unset HTTP_POST_VARS

Posted on 2006-04-08
3
Medium Priority
?
644 Views
Last Modified: 2010-05-18
unset($HTTP_POST_VARS) doesn't work

How can i unset my post variables?
0
Comment
Question by:tolgaong
3 Comments
 
LVL 49

Expert Comment

by:Roonaan
ID: 16410386
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
 
LVL 9

Author Comment

by:tolgaong
ID: 16410629
$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
 
LVL 6

Accepted Solution

by:
ixti earned 1000 total points
ID: 16411291
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

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Suggested Courses
Course of the Month19 days, 5 hours left to enroll

834 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question