English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

How can I make my PHP page check for the address on the address bar and depending on it it does something, for example if you type:
http://anything.com/page.html
and I used the 'print' function to display something and then if you type:
http://anything.com/otherpage.html
I used the same 'print' function to display something different, so basically is like URL tracking but I don't know how to do it.
Please help!

2007-01-18 08:33:55 · 2 answers · asked by Anonymous in Computers & Internet Programming & Design

2 answers

I have a file called pagehead.php that holds the heading and is the same on all the pages. It loads a different css based on what the page is. You can make it print if you want..

The code I use is

$curr = $_SERVER['PHP_SELF']; //this gets the path to the loaded page

$pos = strpos($curr ,'faq/index.php'); //returns the position of 'faq/index.php' in the path
if ( $pos != false ) //if position is not false
{
echo "\n";
}
else if (strpos($curr ,'contact/index.php') != false )
{
echo "\n";
}
....

2007-01-18 09:04:38 · answer #1 · answered by Anonymous · 0 0

in your logic send the function either the page or a different value. in the function have conditionals check the received value and display something accordingly.

2007-01-18 16:43:02 · answer #2 · answered by The_Amish 5 · 0 0

fedest.com, questions and answers