Jump to content

Displaying message based on referral


acctman

Recommended Posts

Hi I need sample code on how to display a message based on referring url/domain.

 

example: if user came from http://www.site1.com/link.php then the message they'd see on http://www.site.com/landing-page.php would be "Welcome Site1 Member's" and if they're coming from site2.com it would say "Site2 Member Welcome".

 

thanks in advance

Link to comment
https://forums.phpfreaks.com/topic/178259-displaying-message-based-on-referral/
Share on other sites

The simple way:

 

<?php
if (isset($_SERVER['HTTP_REFERER'])) {
$info = parse_url($_SERVER['HTTP_REFERER']);
if (isset($info['host'])) {
	echo 'Welcome ' . htmlentities($info['host']) . ' Members.';
} else {
	//invalid referrer
}
} else {
//referrer not set
}
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.