The Little Guy Posted April 9, 2008 Share Posted April 9, 2008 Why does this not work? unset($_POST['submit']); I have this: if(isset($_POST['submit'])){ // Do some code unset($_POST['submit']); } and it always goes into that if when the page is refreshed... I don't want it to. Link to comment https://forums.phpfreaks.com/topic/100352-solved-unset/ Share on other sites More sharing options...
blackcell Posted April 9, 2008 Share Posted April 9, 2008 What are you trying to do? When testing to see if $_POST['submit'] is set, it doesn't need to be unset after the button is pressed. Link to comment https://forums.phpfreaks.com/topic/100352-solved-unset/#findComment-513117 Share on other sites More sharing options...
The Little Guy Posted April 9, 2008 Author Share Posted April 9, 2008 I am submitting a registration form... but... I think I have a better Idea, I think I could just change the value of submit, and match against the value Link to comment https://forums.phpfreaks.com/topic/100352-solved-unset/#findComment-513122 Share on other sites More sharing options...
KevinM1 Posted April 9, 2008 Share Posted April 9, 2008 I am submitting a registration form... but... I think I have a better Idea, I think I could just change the value of submit, and match against the value Still, the question remains: why are you testing against submit? Is it the actual form submission button? Or have you named another form input 'submit'? If it's the former, I can't think of a reason why you'd need to unset it. Link to comment https://forums.phpfreaks.com/topic/100352-solved-unset/#findComment-513133 Share on other sites More sharing options...
blackcell Posted April 9, 2008 Share Posted April 9, 2008 I am submitting a registration form... but... I think I have a better Idea, I think I could just change the value of submit, and match against the value I am curious now, are you going to have multiple submit buttons with different values? If so: <?php //The test for submit if(isset($_POST['submit'])) { $command = trim($_POST['submit']); if ($command == "Submit"){ //Do something } if ($command == "Cancel"){ //Do something else } if ($command == "Edit"){ //Do something else } } //This will allow you to "see" which button was pressed. ?> Link to comment https://forums.phpfreaks.com/topic/100352-solved-unset/#findComment-513160 Share on other sites More sharing options...
uramagget Posted April 9, 2008 Share Posted April 9, 2008 In addition to blackcell's code, attempt using switch() before you create a plethora of messy if statements. if statements still run even if one of the if's conditions are matched. Link to comment https://forums.phpfreaks.com/topic/100352-solved-unset/#findComment-513187 Share on other sites More sharing options...
blackcell Posted April 9, 2008 Share Posted April 9, 2008 Yea, sorry about that, that was a snippet of one of my first programs. Link to comment https://forums.phpfreaks.com/topic/100352-solved-unset/#findComment-513289 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.