![]() |
PHP Question for PHP Pro If I use an include function on my index page, which says something like "if user came from ESPN include Sports.php page, else include Music.php page" so the user will stay on the index.php page but what he is shown will be different based on where he came from, is this something that user can identify? |
Re: PHP Question for PHP Pro Only way I know how to do that is by using 'HTTP Referer'. Unfortunately it's not 100% reliable, because not all browsers support it. But it should work for the majority of your visitors. <?php $referer = $_SERVER['HTTP_REFERER']; // Get the referring URL and put it in a variable if(isset($referer)) // Check to make sure that the variable is set { $espn = strpos($referer, "espn"); // Search the variable to see if it contains "espn" if ($espn === true) { include ('Sports.php'); // If it does, include Sports.php } else { include ('Music.php'); // If it doesn't, include Music.php }} ?> |
Re: PHP Question for PHP Pro Usually we use this to fool SE spiders. It's called "Cloaking". Check the wikipedia article. |
Re: PHP Question for PHP Pro @Brandon Tanner, Can you please advise me, what development environment do you recommend for testing such things on my Windows PC before potentially screwing up an active WordPress blog? |
Re: PHP Question for PHP Pro If you design your site in wordpress then you can do that by adding some plugins. If you are not using wordprees then you have to that by coding php program. |
Re: PHP Question for PHP Pro Quote:
For local testing, I use (and highly recommend) XAMPP. I've never tried to install WP under XAMPP though, as I develop non-WP sites. But I don't see any reason why it wouldn't work. If you only do WP development, then it might be easier for you to use something like this. |
Re: PHP Question for PHP Pro Thanks, Brandon, I will take a look at InstantWP. |
Re: PHP Question for PHP Pro Quote:
|
Re: PHP Question for PHP Pro Quote:
And to the OP: I forgot to mention that 'Http Referer' will only work if the visitor comes to your site via a hyperlink on the referrer's site. If they just type your URL in the address bar or click your link in their 'bookmarks' folder, it won't work. For that reason alone, you're not going to get the referrer info for anywhere near 99% of your visitors. I actually tested this some years ago on one of my sites, and if I recall correctly, it was more in the 60 - 70% range. So just something to keep in mind. |
Re: PHP Question for PHP Pro Quote:
|
| All times are GMT -6. The time now is 12:46 PM. |