Hi

I'm trying to write a small foreach loop that will empty all POST vars received by the page

this doesn't work :

	

foreach($HTTP_POST_VARS as $k => $var){
$k = "";
}

so I'm obviously overlooking a basic thing ...

has anyone got a simple way of doing this ?

thanks

    oops i posted the wrong bit :

    	foreach($HTTP_POST_VARS as $k => $var){
    		$HTTP_POST_VARS[$k] = "";
    	}

      Eh, why do you want to do this? It depends on what you mean by empty, but it could be:

      foreach ($_POST as $key => $value) {
          unset($_POST[$key]);
      }

      I see it as rather pointless.

        I suppose

        $_POST = array();

        would work too if you just want to get rid of all of them

          laserlight wrote:

          Eh, why do you want to do this?

          so that when the form is sent and the page is re-displayed with the success message, all of the form fields are empty

          and your solution works fine

          thank you

            ah yes - an even simpler solution, leatherback

            thanks

              so that when the form is sent and the page is re-displayed with the success message, all of the form fields are empty

              Okay, that sounds fine, if you really do intend to display the form after processing.

              and your solution works fine

              I think leatherback's solution should work better.

              Remember to mark this thread as resolved (if it is).

                Write a Reply...