asloan Posted January 6, 2009 Share Posted January 6, 2009 Ok...programming background but not in PHP http://www.benedictinebusiness.org/index.php?option=com_content&view=article&id=19&Itemid=27 I'm trying to create an if statement to check if the option value if null - basically i'm trying to check if it's the homepage and if it's the homepage I would like a different background color to display then the interior pages. But I first need to check if it's the homepage. Soo far it always shows that options is null. if($_request['option'] == ''){ echo "hello andrea"; } Any ideas? Thank you, Andrea Link to comment https://forums.phpfreaks.com/topic/139692-solved-if-then/ Share on other sites More sharing options...
flyhoney Posted January 6, 2009 Share Posted January 6, 2009 I think you want something like this: <?php if (isset($_GET['option']) && $_GET['option'] == 'com_content') { echo 'hello andrea'; } ?> Link to comment https://forums.phpfreaks.com/topic/139692-solved-if-then/#findComment-730885 Share on other sites More sharing options...
asloan Posted January 6, 2009 Author Share Posted January 6, 2009 I put the code in and no luck I still receive hello andrea.. Link to comment https://forums.phpfreaks.com/topic/139692-solved-if-then/#findComment-730891 Share on other sites More sharing options...
revraz Posted January 6, 2009 Share Posted January 6, 2009 And you would since the URL is setting OPTION. Try this instead http://www.benedictinebusiness.org/index.php?option=nothing&view=article&id=19&Itemid=27 Link to comment https://forums.phpfreaks.com/topic/139692-solved-if-then/#findComment-730892 Share on other sites More sharing options...
asloan Posted January 6, 2009 Author Share Posted January 6, 2009 I guess I'm a little confused. The option is part of the url...and is pulled from the database so I can't change it to nothing. basically the homepage is www.benedictinebusiness.org and there is nothing else in the url. Link to comment https://forums.phpfreaks.com/topic/139692-solved-if-then/#findComment-730898 Share on other sites More sharing options...
flyhoney Posted January 6, 2009 Share Posted January 6, 2009 Ah, so you're saying if 'option' is NOT set in the URL, then that is the homepage? If thats the case this should work: <?php if (!isset($_GET['option'])) { echo 'THIS IS THE HOMEPAGE'; } ?> Link to comment https://forums.phpfreaks.com/topic/139692-solved-if-then/#findComment-730902 Share on other sites More sharing options...
asloan Posted January 6, 2009 Author Share Posted January 6, 2009 Exactly! but it's not working.....soo maybe I'm missing it..... www.benedictinebusiness.org = homepage http://www.benedictinebusiness.org/index.php?option=com_content&view=article&id=45&Itemid=60 = interior page is there another way I can check to see if it's the homepage? Link to comment https://forums.phpfreaks.com/topic/139692-solved-if-then/#findComment-730908 Share on other sites More sharing options...
flyhoney Posted January 6, 2009 Share Posted January 6, 2009 <?php if (!isset($_GET['option'])) { die('THIS IS THE HOMEPAGE'); } ?> Should work, I don't know why it wouldn't. You could also try this: <?php if (!$_SERVER['QUERY_STRING']) { die('THIS IS THE HOMEPAGE'); } ?> Link to comment https://forums.phpfreaks.com/topic/139692-solved-if-then/#findComment-730912 Share on other sites More sharing options...
asloan Posted January 6, 2009 Author Share Posted January 6, 2009 AWESOME!!!! This works...thank you for being patient and helping me out <?php if (!$_SERVER['QUERY_STRING']) { die('THIS IS THE HOMEPAGE'); } ?> Link to comment https://forums.phpfreaks.com/topic/139692-solved-if-then/#findComment-730923 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.