Left Quote    Every day I get up and look through the Forbes list of the richest people in America. If I
- Robert Orben    
Right Quote
[login] | [Register]

Accept Coupon Codes for Downloads

by: sm0ke
Page: 2 of 3
(View All)

Using a form to enter the coupon code

Right, lets pretend the user has selected a file to download, they click to pay with a coupon for a free download - we need to present the user with a form to enter the coupon code to enable the download of the correct file.

In the following file we need to call in the information from the database on the download file requested. so a good link to use to get to enter the code from your products page might be{id} Lets take a look at the form

Now we have a way for the user to enter a coupon code to download the selected product, save the file as coupon.php under the root of your site.

Verify code and direct to download

Now the above file will use a form action pointing to "verify.php" sending the hidden download id and coupon code along with it. The following file needs to be saved as "verify.php" under your root directory, this file will grab both the download id field and coupon code from the database, verify that the code and file exist and if either is false (doesnt exist) it will exit, if both download and code are ok the user will be directed to the download script to grab the file and the code will be deleted from the database so it cant be reused.

in the above file the variable $querystring points to the field called "file" on the downloads table and adds the .zip extension to said filename, remember, we said not to store the file extension in the database, thats why.

1  |  2  |  3  |  
Next »

No Comments for this page.

You Must be logged in or a member to comment.

Tutorial Stats

Tutorial Stats

4 Total Comments
3 Rating of 5 (1 Votes)


Tutorial Options

· Login to Rate This Article
· Login to Post a Comment
· Read more by this author
Digg This Article! Bookmark This Article Reddit: Bookmark This Article BlinkList: Blink This Article! YahooMyWeb BlogMarks: Add This Mark! Furl: Save This Article Spurl: Mark This Article



· Simple PHP Tutorial
· One File Website
· Pagination with PHP
· Building a Comments Script
· Complete Members System
· Variable Scope

"" Copyright © 2002-2018; All rights lefted, all lefts righted.
Privacy Policy  |  Internet Rank