Eminem Posted August 24, 2007 Share Posted August 24, 2007 How can I go about making it so that two codes will be executed in an "else"? <?php if ($user = " ") echo "Please specify a username!"; elseif ($pass = " ") echo "Please enter your password!"; else mail($to,$subject,$message); echo "Hello World!" ?> I want else to run not only mail, but Hello World! too. I want it so that Hello World! doesn't show up in the if and elseif situations... only in an else situation. Link to comment https://forums.phpfreaks.com/topic/66585-solved-php-else-two-codes-executed/ Share on other sites More sharing options...
trq Posted August 24, 2007 Share Posted August 24, 2007 Use braces. <?php if ($user = " ") { echo "Please specify a username!"; } elseif ($pass = " ") { echo "Please enter your password!"; } else { mail($to,$subject,$message); echo "Hello World!"; } ?> Link to comment https://forums.phpfreaks.com/topic/66585-solved-php-else-two-codes-executed/#findComment-333535 Share on other sites More sharing options...
matthewhaworth Posted August 25, 2007 Share Posted August 25, 2007 I think you're using the wrong operator for your $user and $pass check, it's == not = Link to comment https://forums.phpfreaks.com/topic/66585-solved-php-else-two-codes-executed/#findComment-333620 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.