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. Quote Link to comment 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. Quote Link to comment 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? Quote Link to comment 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. Quote Link to comment 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. Quote Link to comment 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.