Jump to content

stupid form question...very easy.


Chud37

Recommended Posts

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??

Link to comment
https://forums.phpfreaks.com/topic/207703-stupid-form-questionvery-easy/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.