Wildhalf Posted March 8, 2007 Share Posted March 8, 2007 Hi, I have a quick qustion. I want to know who what URL or website sent the visitor to a certain page. I am looking into it as we speak and was wondering if anyone knew if this would work... $referrer = $_SERVER['HTTP_REFERER']; Link to comment https://forums.phpfreaks.com/topic/41746-solved-a-quick-one-for-you/ Share on other sites More sharing options...
papaface Posted March 8, 2007 Share Posted March 8, 2007 yes that would work. Link to comment https://forums.phpfreaks.com/topic/41746-solved-a-quick-one-for-you/#findComment-202383 Share on other sites More sharing options...
Wildhalf Posted March 8, 2007 Author Share Posted March 8, 2007 Thank you for that Just installed XAMPP and tested it it does work... One last question... $referrer = $_SERVER['HTTP_REFERER']; $referrer will display the whole url is there any way for extracting just the domain name from this.... What i am doing is if the url is one thing dispay one page if it's another display a different page completely Link to comment https://forums.phpfreaks.com/topic/41746-solved-a-quick-one-for-you/#findComment-202387 Share on other sites More sharing options...
Wildhalf Posted March 8, 2007 Author Share Posted March 8, 2007 Sorted Myself..... Basicaly the code below searchs the url that sent a visitor to the site and extracts the word test from it and prints it out..... You can change test to what ever you want <? $referrer = $_SERVER['HTTP_REFERER']; //echo "$referrer"; echo $referrer; echo '<br />'; ereg ("test", $referrer, $domain); If ($domain[0] == 'test'){ echo 'This works </br>'; } echo $domain[0]; // prints @example.com ?> Link to comment https://forums.phpfreaks.com/topic/41746-solved-a-quick-one-for-you/#findComment-202416 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.