PHP Referrer – HTTP Referrer
Suppose user submits a form and post data to the other page. We can find out its referrer URL (From where he came?) for redirection or other purpose.
Referrer can be used in following ways.
- Redirection (Redirect back from where the form was posted, lets say after mailing…)
- To referrer a web page to a friend.
Printing HTTP Referrer
Redirection With HTTP Referrer
$ref = @$HTTP_REFERER;
// print $ref;
*** Redirection With HTTP Referrer While Globals Are Off ***
For more reference on this proceed here.
Variable $ref contains the value of referring page.
Consider Redirection After Mail Script
$subject= "Your friend has referred you this link from www.sitename.com";
$subject= "$fromName has referred you this link from www.sitename.com";
$message = "
Your friend $fromName has referred this link to you.
Please visit this link by clicking $ref
$from = "From: $fromEmail\r\n";
mail($toEmail, $subject, $message, $from);
Download HTTP Referrer Script