soma56 Posted October 19, 2010 Share Posted October 19, 2010 Is it possible to unset a submit button? <?PHP if(isset($_POST['Submit'])) { $date = $_POST['date']; if ($date = '1966-10-03'){ //Do Something } else { //Possible to unset? unset($date); unset($_POST['Submit']); } } else { ?> <form action="" method="post"> <input type="text" name="date" /> <input type="Submit" name="Submit" value="Submit" /> </form> <?PHP } ?> What I'm wondering is if it's possible to unset after submitting in the event of condition x. Should this not in turn echo out the form as it has been unset? Link to comment https://forums.phpfreaks.com/topic/216260-unset-isset-_post-is-it-possible/ Share on other sites More sharing options...
fortnox007 Posted October 19, 2010 Share Posted October 19, 2010 I bet it's possible just do print_r ($_POST); before and after and look at the output. It will show the elements in the array $_POST Link to comment https://forums.phpfreaks.com/topic/216260-unset-isset-_post-is-it-possible/#findComment-1123864 Share on other sites More sharing options...
fortnox007 Posted October 19, 2010 Share Posted October 19, 2010 Just to show you can, test this script: $_POST['monkeyballs']='lalala'; print_r($_POST); // outputs: Array ( [monkeyballs] => lalala ) unset($_POST['monkeyballs']); print_r($_POST); //outputs: Array ( ) Link to comment https://forums.phpfreaks.com/topic/216260-unset-isset-_post-is-it-possible/#findComment-1123868 Share on other sites More sharing options...
BlueSkyIS Posted October 19, 2010 Share Posted October 19, 2010 Should this not in turn echo out the form as it has been unset? [/quote no. you check whether it is set when you enter the IF. unsetting it after you enter the IF doesn't make the IF false. Link to comment https://forums.phpfreaks.com/topic/216260-unset-isset-_post-is-it-possible/#findComment-1123872 Share on other sites More sharing options...
sastro Posted October 19, 2010 Share Posted October 19, 2010 Try this <?PHP if(isset($_POST['Submit'])) { $date = $_POST['date']; if ($date = '1966-10-03'){ //Do Something $submitx=1; } else { //Possible to unset? unset($date); unset($_POST['Submit']); } } if($submitx==0){ ?> <form action="" method="post"> <input type="text" name="date" /> <input type="Submit" name="Submit" value="Submit" /> </form> <?PHP } ?> Link to comment https://forums.phpfreaks.com/topic/216260-unset-isset-_post-is-it-possible/#findComment-1123873 Share on other sites More sharing options...
BlueSkyIS Posted October 19, 2010 Share Posted October 19, 2010 you probably want something more like <?php if(isset($_POST['date']) && $_POST['date'] == '1966-10-03') { //Do Something } else { ?> <form action="" method="post"> <input type="text" name="date" /> <input type="Submit" name="Submit" value="Submit" /> </form> <?php } ?> Link to comment https://forums.phpfreaks.com/topic/216260-unset-isset-_post-is-it-possible/#findComment-1123876 Share on other sites More sharing options...
soma56 Posted October 20, 2010 Author Share Posted October 20, 2010 Nice. This forum rocks and you guys are great. Link to comment https://forums.phpfreaks.com/topic/216260-unset-isset-_post-is-it-possible/#findComment-1124267 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.