![]() |
|
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 http://www.somesite.com/coupon.php?id={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.
No Comments for this page. |
![]() |