Alright, heres the question. I have a script that runs off of the index.php.. It is my template. I want to have a intro paragraph that I ONLY want to show up when the user is at the main page. I have tried using these php codes to make it only show on the main page, but it continues to show up on all of the pages. <? $url=$_SERVER['REQUEST_URI']; $url=explode(".com",$url); $check=$url[1]; if($check=="/") { echo "paragraph blah blah blah blah"; } ?> PHP: and then, <? if ($_SERVER['REQUEST_URI']== "http://www.url.com"); { echo "paragraph blah blah blah blah"; } ?> PHP: Both of these didn't work, any ideas of why or what I can change to make them work.. or if I need to use something completely different. Anyone that can help will get a big thanks and a hug?. Thanks Zack B
Find out your SCRIPT_FILENAME variable, paste this into a file (which you can delete when you're done) <?php echo phpinifo(); ?> Find _SERVER["SCRIPT_FILENAME"], near the bottom. Copy the value of that.. e.g. /var/www/domain.com/index.php and paste it into $filename below Then <?php $filename = "/var/www/domain.com/index.php"; if($_SERVER["SCRIPT_FILENAME"] = $filename && (count($_SERVER["argv"]) == 0)) { echo "paragraph"; } ?> PHP: That should work.. it will only show if the query string is empty (i.e. index.php and not index.php?page=info)
I thought this would work.. but it sadly didn't... :-( Do you have any other ideas? Anyone else see why this wouldn't work? Any helps would be quite helpful! _Zack
The operator is wrong, it should be '==' instead of '=' and i would include some additional brackets, ie: if(($_SERVER["SCRIPT_FILENAME"] == $filename) && (count($_SERVER["argv"]) == 0)) { Code (markup): If you only have 1 index.php, you could simplify the whole thing and use this: if (basename($_SERVER["SCRIPT_FILENAME"]) == "index.php") { //your code } Code (markup):
Try this <?php $file_path = substr($_SERVER['REQUEST_URI'], $ini_substr, strlen($_SERVER['REQUEST_URI'])); $uri = explode('?', $file_path); if ($uri[0] == "/" OR $uri[0]== "index.php") { echo "your paragraph"; } ?> Code (markup):
This one worked like a charm... THANKS A LOT! You get a "hug"... and so does everyone else.. Thanks guys. This is why I love this forum.. resources at your finger tips! Regards, Zack B