dadamssg Posted November 15, 2010 Share Posted November 15, 2010 I'm developing a javascript widget to display on other people's websites that will have a php file(on my hosting account) as its source. Is there a way for php to get the domain of the site that is requesting the php file? I want the user to be able to specify if they want the widget to only display on their website. So i would store the user's domain name in my db and then write in the php script to check to see if the website requesting the widget matches whats in my db...if so display widget...if not..don't. Quote Link to comment https://forums.phpfreaks.com/topic/218786-way-to-find-the-domain-that-is-requesting-a-php-script/ Share on other sites More sharing options...
Rifts Posted November 15, 2010 Share Posted November 15, 2010 $_SERVER['HTTP_REFERER'] Quote Link to comment https://forums.phpfreaks.com/topic/218786-way-to-find-the-domain-that-is-requesting-a-php-script/#findComment-1134715 Share on other sites More sharing options...
dadamssg Posted November 15, 2010 Author Share Posted November 15, 2010 not working.... <?php echo $_SERVER['HTTP_REFERER']; ?> displays nothing... Quote Link to comment https://forums.phpfreaks.com/topic/218786-way-to-find-the-domain-that-is-requesting-a-php-script/#findComment-1134723 Share on other sites More sharing options...
dadamssg Posted November 16, 2010 Author Share Posted November 16, 2010 echo $_SERVER['SERVER_NAME']; works! Quote Link to comment https://forums.phpfreaks.com/topic/218786-way-to-find-the-domain-that-is-requesting-a-php-script/#findComment-1134737 Share on other sites More sharing options...
jcbones Posted November 16, 2010 Share Posted November 16, 2010 It should work, that is your server name. You should try $_SERVER['REMOTE_HOST'] or maybe gethostbyaddr() Quote Link to comment https://forums.phpfreaks.com/topic/218786-way-to-find-the-domain-that-is-requesting-a-php-script/#findComment-1134741 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.