thepassionofchad Posted March 17, 2008 Share Posted March 17, 2008 Hi, I'm quite new to php and coding in general. I need a script that would display another php script only if someone was sent to the page from a specific referer. Can anyone help me out here? Thanks from the noob. Link to comment https://forums.phpfreaks.com/topic/96484-display-php-script-only-if-from-referer/ Share on other sites More sharing options...
Jeremysr Posted March 17, 2008 Share Posted March 17, 2008 $_SERVER['HTTP_REFERER'] contains the referral URL. Remember that it gets sent by the browser so it can't be trusted 100%. If the referral URL is on your site you could use sessions to get the referral URL. Link to comment https://forums.phpfreaks.com/topic/96484-display-php-script-only-if-from-referer/#findComment-493774 Share on other sites More sharing options...
thepassionofchad Posted March 17, 2008 Author Share Posted March 17, 2008 Sorry, I'm a bit more of a noob than that. I did a little more research, so it goes: <?php if ($_SERVER['HTTP_REFERER']="https://www.link.com"){ include('script.php'); } ?> ----------------------------------- So if the person comes through link.com, then the page will include script.php? Link to comment https://forums.phpfreaks.com/topic/96484-display-php-script-only-if-from-referer/#findComment-493827 Share on other sites More sharing options...
Jeremysr Posted March 17, 2008 Share Posted March 17, 2008 Yes, but = is the assignment operator, you should be using == to compare things. Also they could probably leave out the "www." and then it wouldn't work. Or put a slash at the end of the URL. So you'll have to check the HTTP_REFERER with those too. Link to comment https://forums.phpfreaks.com/topic/96484-display-php-script-only-if-from-referer/#findComment-493830 Share on other sites More sharing options...
thepassionofchad Posted March 17, 2008 Author Share Posted March 17, 2008 Thanks, I'll try it out and see if it works alright for the site. Link to comment https://forums.phpfreaks.com/topic/96484-display-php-script-only-if-from-referer/#findComment-493834 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.