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? Quote Link to comment 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 Quote Link to comment 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 ( ) Quote Link to comment 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. Quote Link to comment 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 } ?> Quote Link to comment 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 } ?> Quote Link to comment 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. Quote Link to comment 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.