Very simple question for you php'ers! What is the best way to do the following: Have someone pay a few dollars through paypal to view the content of my site? They can view it as many times as possible after they pay but up until then they must pay first? Vague? Maybe, but its very straightforward - I just want someone to have to click straight into paypal, pay 2 dollars and then redirected back to another part of the site where they get to view the content? Thank you
<?php $ref = $_SERVER['HTTP_REFERER']; // Get the referer URL if(preg_match("/paypal.com/",$ref)) { // IF referer URL contains "paypal.com" then echo the content echo "Here's your content :)"; } else { echo "You must pay first"; } // else show error message ?> PHP: No security (referer can be faked), but should do the trick
Thank you for the swift reply iAreCow. 2 questions: Any way of making it secure? And, the visitor couldn't make a return visit without re-paying, am I wrong? Many thanks.
Create a simple login system, and save the payment status to their profile in the database. Then ask people to log in to view content on your site, redirecting them if they haven't paid
Hi Jay, yeah thats definitely what I'm after - novice phper - any links to such a simple login etc that would survice? Thank you
for the login tutorial, check out http://www.deathmonkeyz.com/tutorials (in the php section) For the paypal integration, check out their API and google around a bit. Modifying the code shouldn't prove too difficult
Security: 1. You could use PayPal IPN: customer pays, returns to your side with a unique transaction ID, the script checks if the ID is valid (a simple query to PayPal) and prints the content if it is. Returning visitor: 1. Save the transaction ID in cookies (user will have access till he deletes the cookie or uses another browser) 2. Work out some login system 3. You could mail() them the content