Jump to content

showing a page based on http referrer


Prodigal Son

Recommended Posts

I set paypal donation button that sends them to a page with a message after they donate. I don't want anyone to just type in the url and be able to see this page, so I did this:

<?php
if (strpos($_SERVER['HTTP_REFERER'], "paypal.com"))
{
?>
<p>Message here</p>
<?php
}
else
{
header('location: /404error/');
}
?>

I got a friend to test it and it didn't work. After he donated it went to the 404 page instead of the page with the message. Did I mess up something, is there a better way to do it than this?

Link to comment
https://forums.phpfreaks.com/topic/118783-showing-a-page-based-on-http-referrer/
Share on other sites

to check what is sent back do this:

 

echo '<pre>';
print_r($_SERVER);
echo '</pre>';

Ok I saw all the server variables, I couldn't find HTTP_REFERER in the list, so I guess it was blank.

 

Also, not all browsers set the referrer and it can be tampered with.  Don't rely on it.

Hmm, so is there another way to do this?

You could link the Paypal button to a PHP script that sets a session variable and then sends them off to Paypal. >_>

Hmm, how would I do that? Or maybe I can also create a cookie with a JS onclick and check if the cookie exists? But even if you did that, it only means after they clicked on the button they can see the page. They could just click it and even if they don't donate they can see the page if they know the url. Actually there's nothing really important on that page, I don't even know why I care lol, maybe I should just leave it public?

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.