Chud37 Posted July 14, 2010 Share Posted July 14, 2010 Look at this code: <?php if(isset($_POSt['ringo'])) { if($_POST['ringo']=='jolly') {echo "jolly";} if($_POST['ringo']=='polly') {echo "polly";} } switch ($_POST['ringo']) { case 'jolly': echo "jolly"; break; case 'polly': echo "polly"; break; } ?> <br><br> <form method="post"> <input type="text" size=10 name="abs"> <input type="submit" value="jolly" name="ringo"> <input type="submit" value="polly" name="ringo"> </form> Now can anyone tell me why using the switch statement works and the if statement doesnt. I though, maybe its because Im using double quotes and the switch isnt. But thats not the case. Can anyone explain this?? Quote Link to comment https://forums.phpfreaks.com/topic/207703-stupid-form-questionvery-easy/ Share on other sites More sharing options...
Fergal Andrews Posted July 14, 2010 Share Posted July 14, 2010 Hi Chud37, I haven't tested the code but you have $_POSt instead of $_POST in your if statement. All the best, Fergal Quote Link to comment https://forums.phpfreaks.com/topic/207703-stupid-form-questionvery-easy/#findComment-1085769 Share on other sites More sharing options...
trq Posted July 14, 2010 Share Posted July 14, 2010 It never executes. if(isset($_POSt['ringo'])) { should be.... if(isset($_POST['ringo'])) { Quote Link to comment https://forums.phpfreaks.com/topic/207703-stupid-form-questionvery-easy/#findComment-1085771 Share on other sites More sharing options...
Chud37 Posted July 14, 2010 Author Share Posted July 14, 2010 annyoing. I hate it when i make stupid errors like that. so much for my first post being something significant hey. thanks alot people Quote Link to comment https://forums.phpfreaks.com/topic/207703-stupid-form-questionvery-easy/#findComment-1085777 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.