Prodigal Son Posted August 8, 2008 Share Posted August 8, 2008 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 More sharing options...
The Little Guy Posted August 8, 2008 Share Posted August 8, 2008 <?php if (preg_match("/paypal.com/",$_SERVER['HTTP_REFERER'])) { ?> <p>Message here</p> <?php } else { header('location: /404error/'); } ?> Link to comment https://forums.phpfreaks.com/topic/118783-showing-a-page-based-on-http-referrer/#findComment-611581 Share on other sites More sharing options...
Prodigal Son Posted August 8, 2008 Author Share Posted August 8, 2008 Hmm, still doesn't work. Could it not be a problem with the code and that paypal somehow doesn't let you receive the referer? Would there be another way to do this? Link to comment https://forums.phpfreaks.com/topic/118783-showing-a-page-based-on-http-referrer/#findComment-611642 Share on other sites More sharing options...
The Little Guy Posted August 8, 2008 Share Posted August 8, 2008 to check what is sent back do this: echo '<pre>'; print_r($_SERVER); echo '</pre>'; Link to comment https://forums.phpfreaks.com/topic/118783-showing-a-page-based-on-http-referrer/#findComment-611662 Share on other sites More sharing options...
DarkWater Posted August 8, 2008 Share Posted August 8, 2008 Also, not all browsers set the referrer and it can be tampered with. Don't rely on it. Link to comment https://forums.phpfreaks.com/topic/118783-showing-a-page-based-on-http-referrer/#findComment-611666 Share on other sites More sharing options...
Prodigal Son Posted August 8, 2008 Author Share Posted August 8, 2008 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? Link to comment https://forums.phpfreaks.com/topic/118783-showing-a-page-based-on-http-referrer/#findComment-611695 Share on other sites More sharing options...
DarkWater Posted August 8, 2008 Share Posted August 8, 2008 You could link the Paypal button to a PHP script that sets a session variable and then sends them off to Paypal. >_> Link to comment https://forums.phpfreaks.com/topic/118783-showing-a-page-based-on-http-referrer/#findComment-611700 Share on other sites More sharing options...
Prodigal Son Posted August 8, 2008 Author Share Posted August 8, 2008 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? Link to comment https://forums.phpfreaks.com/topic/118783-showing-a-page-based-on-http-referrer/#findComment-611737 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.