Re: [PHP] register_globals off issues

[email protected] (Ernest E Vogelsinger) Tue, 12 Nov 2002 21:38:05 +0100
Newsgroups php.general,php.lang
Message-ID <[email protected]>
At 21:05 12.11.2002, Mark Spohr said:
--------------------[snip]--------------------
>I'm trying to convert this to use $_POST() as such:
>
>  if (@$_POST['form'] == "yes")
>{
>unset($_POST['form']);
>}
>
>However, this does not work. It appears that you can't unset the 
>$_POST['form'] array element.
--------------------[snip]-------------------- 

unset() works for any variable - also for the superglobals like $_POST.
Try this:

--------------------[cut here]-------------------- 
<xmp>
<?php
print_r($_POST);
echo 'F1 = ', $_POST['f1'], "\nF2 = ", $_POST['f2'], "\n";
unset($_POST['f2']);
print_r($_POST);
?>
</xmp>
<form method="POST">
<input type="text" name="f1" value="<?php echo $_POST['f1'];?>">
<br>
<input type="text" name="f2" value="<?php echo $_POST['f2'];?>">
<br>
<input type="submit">
</form>
--------------------[/cut here]-------------------- 

What error do you get? Make sure you're using the correct case - PHP is
case sensitive in variable names and associative index keys...


-- 
   >O     Ernest E. Vogelsinger
   (\)    ICQ #13394035
    ^     http://www.vogelsinger.at/