DarkHorizon Posted October 19, 2006 Share Posted October 19, 2006 Hi folks, its the age old question...i have some mp3 files that are available for sale. I want customers to pay for them using paypal then download them once payment has been taken. I am familiar with PayPal integration into a 3rd party (my) PHP shopping cart.How do i restrict access to a file on a server such as an MP3 until the user has paid?Just some rough ideas, a plan would be great. You dont have to offer any code, i know you are busy enough witout me butting in. Quote Link to comment Share on other sites More sharing options...
trq Posted October 19, 2006 Share Posted October 19, 2006 Place the files in a non accessible directory, with there filenames and paths stored in a database. You then use the [url=http://php.net/header]header[/url] function to force a download once authorized. Quote Link to comment Share on other sites More sharing options...
Design Posted October 19, 2006 Share Posted October 19, 2006 you could use a variable with a boolean(true/false) value, so that if it's not paid for, say $paid = false, you restrict the page by checking the value of $paid when the page loads, if false then redirect, otherwhise let them continue. Quote Link to comment Share on other sites More sharing options...
printf Posted October 19, 2006 Share Posted October 19, 2006 place the files in a no web access directory, then serve them via PHP...[code]// no web access directory and file paid for!$file = '/path/paid.mp3';if ( has been paid logic ){ if ( not dowloaded already logic OR allowed download time limit logic < time () ) { header ( 'Cache-control: max-age=31536000' ); header ( 'Expires: Mon, 26 Jul 1997 05:00:00 GMT' ); header ( 'Content-Length: ' . filesize ( $file ) ); header ( 'Content-Disposition: filename="' . basename ( $file ) . '"' ); header ( 'Content-Type: application/download; name="' . basename ( $file ) . '"' ); readfile ( $file ); } else { echo 'sorry you already downloaded this music file'; }}else{ echo 'sorry you have not paid to use this service!';}[/code]me! Quote Link to comment Share on other sites More sharing options...
DarkHorizon Posted October 19, 2006 Author Share Posted October 19, 2006 thanks,now i can make a start on building it up.. 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.