virken Posted December 22, 2006 Share Posted December 22, 2006 Hi, I've tried several ways to unset my $_POST['Submit'] variable but the only thing that seems to work is killing the session.Isn't there something a bit more eloquent than that?Thanks much for all the help :-) Quote Link to comment https://forums.phpfreaks.com/topic/31563-how-to-unset-_post/ Share on other sites More sharing options...
trq Posted December 22, 2006 Share Posted December 22, 2006 Have you tried?[code=php:0]unset($_POST['Submit']);[/code]Otherwise, $_POST['Submit'] has nothing to do with sessions, you'll need to explain what it is youv'e done and are trying to do. Quote Link to comment https://forums.phpfreaks.com/topic/31563-how-to-unset-_post/#findComment-146272 Share on other sites More sharing options...
taith Posted December 22, 2006 Share Posted December 22, 2006 $_POST[] vars are [u]read only[/u] you cant activly create/change/alter/delete these vars other then by a form, or by changing to a different page. Quote Link to comment https://forums.phpfreaks.com/topic/31563-how-to-unset-_post/#findComment-146343 Share on other sites More sharing options...
alpine Posted December 22, 2006 Share Posted December 22, 2006 Test:[code]<?php$_POST['one'] = "This is a post included:";$_POST['two'] = "- post two";$_POST['three'] = "- post three";if($_POST == true){ foreach($_POST as $value){ echo $value." "; } echo "<br />";}$_POST['two'] = false;if($_POST == true){ foreach($_POST as $value){ echo $value." "; } echo "<br />";}$_POST = false;if($_POST == true){ foreach($_POST as $value){ echo $value." "; }}else{ echo "No post is set";}?>[/code]Outputs:[quote]This is a post included: - post two - post threeThis is a post included: - post threeNo post is set[/quote] Quote Link to comment https://forums.phpfreaks.com/topic/31563-how-to-unset-_post/#findComment-146344 Share on other sites More sharing options...
HuggieBear Posted December 22, 2006 Share Posted December 22, 2006 [quote author=taith link=topic=119602.msg490111#msg490111 date=1166784908]$_POST[] vars are [u]read only[/u] you cant activly create/change/alter/delete these vars other then by a form, or by changing to a different page.[/quote]You can unset() them though. Try running this piece of code and seeing how many times it echo's what you type in the field:[code]<form method="POST"> <input type="text" name="vartest"> <input type="submit" name="submit"></form><?phpecho $_POST['vartest'];unset($_POST['vartest']);echo $_POST['vartest'];?>[/code]RegardsHuggie Quote Link to comment https://forums.phpfreaks.com/topic/31563-how-to-unset-_post/#findComment-146345 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.