MrXander Posted September 9, 2007 Share Posted September 9, 2007 Hi There, I was wodnering if anyone can help me. I am currently developing a site that requires users to sign up. I completely forgot to add a piece of code to every page to see if the user is logged in. So what I want to do, is something like this: Baring in mind, $c is defined earlier as $_GET['c']; if ($cookie){ if ($c == "forums"){ echo "You are not logged in"; } } Something similar to that, but obviously I would need a list of like, 15-20 pages. Is there any way I can put all the page names in an array then check them in an IF statement? Quote Link to comment https://forums.phpfreaks.com/topic/68599-if-statement-with-array/ Share on other sites More sharing options...
pocobueno1388 Posted September 9, 2007 Share Posted September 9, 2007 Maybe something like this: <?php $pages = array("forums", "chat", "news", "something"); if (in_array($c, $pages)){ echo "You are not logged in"; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/68599-if-statement-with-array/#findComment-344833 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.