Jump to content

pass server url from site to site


hack4lk

Recommended Posts

Hello everyone, I was just wondering if there is a way to pass the main server url from one site to another because I would like to build a simple referral system that when someone clicks on a referral link in www.site1.com/sample.html , they are redirected to www.site2.com/referral.php, which catches the first url and says something like "thank you for visiting our sister site www.site1.com, please proceed".

I know that I can use $_SERVER to hold the variable locally but how do i pass that through a url and strip away everyting but the server url....thanks a lot in advance.
Link to comment
https://forums.phpfreaks.com/topic/3866-pass-server-url-from-site-to-site/
Share on other sites

change sample.html to sample.php to start, then where you link to the seconds site simply add:

[code]http://www.site1.com/referral.php?ref=site1[/code]

then go to referral.php and add:

[code]
$referrer = $_GET['ref'];
[/code]

Then still in referral.php wherever you want it to say "thank you for visiting our sister site www.site1.com, please proceed" just add:

[code]
echo "thank you for visiting our sister site $referrer, please proceed";
[/code]

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.