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. Quote Link to comment 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!"; } ?> Quote Link to comment 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 = 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.