bwielk Posted March 29, 2016 Share Posted March 29, 2016 Hello guys! I have literally started learning how to code. And I have come to the point when I got to deal with elseif syntax which is not working properly and messes up everything I have done so far. Here's the script $password = "tulip"; if ($password == "tulip") { echo '<b>Hello!</b><br> Welcome to the website Blaise!'; } else { echo '<b> The password or login is incorrect <br> Please try again </b>'; } elseif ( $password == "daisy") { echo '<b> Welcome Kate! </b>; } When I type in "daisy" nothing goes on and everything just gets stuck. Any help or explanation? Thanks Quote Link to comment https://forums.phpfreaks.com/topic/301103-elseif-syntax/ Share on other sites More sharing options...
Solution Jacques1 Posted March 29, 2016 Solution Share Posted March 29, 2016 You can't have an "elseif" after an "else". The "else" marks the end of the statement (as in: If none of the above is true, execute the following code). It's if (...) { ... } elseif (...) { ... } elseif (...) { ... } ... else { ... } If your code "just gets stuck", that means you need to fix your error reporting as well. PHP always tells you exactly what's wrong. Quote Link to comment https://forums.phpfreaks.com/topic/301103-elseif-syntax/#findComment-1532535 Share on other sites More sharing options...
bwielk Posted March 29, 2016 Author Share Posted March 29, 2016 Thanks a lot for your help! Now it's working as it's supposed to Quote Link to comment https://forums.phpfreaks.com/topic/301103-elseif-syntax/#findComment-1532554 Share on other sites More sharing options...
ginerjm Posted March 29, 2016 Share Posted March 29, 2016 Read a book. Check out codeacademy online. There's a lot to learn to become a coder, let alone a good one. Make it easier on yourself with some basic walk-before-you-run efforts. Quote Link to comment https://forums.phpfreaks.com/topic/301103-elseif-syntax/#findComment-1532559 Share on other sites More sharing options...
bwielk Posted March 29, 2016 Author Share Posted March 29, 2016 For the beginning, I'd rather watch some videos about how to code and after that, when I have understood more about basics and what's syntax and what's variable, to proceed to some books as I am more of a visual rather than a reader. Thanks a lot for Your advice, though. If You have more suggestions or recommendations, I am open towards everything Quote Link to comment https://forums.phpfreaks.com/topic/301103-elseif-syntax/#findComment-1532594 Share on other sites More sharing options...
QuickOldCar Posted March 31, 2016 Share Posted March 31, 2016 Try starting to learn at php.net , is a lot of bad or outdated code around on the internet. Quote Link to comment https://forums.phpfreaks.com/topic/301103-elseif-syntax/#findComment-1532633 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.