Search
Left Quote    A clever person solves a problem. A wise person avoids it.
- Einstein    
Right Quote
 
[login] | [Register]
 

Accept Coupon Codes for Downloads

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

Introduction


This tutorial may be useful if you want to deliver downloads using coupon codes to verify authorization to access the file. This method is in no way secure and should not be run on a production environment but is mereley to introduce a quick and easy method to verify coupon codes and direct customers to the correct file requested.

Create the Tables
Firstly we need to create the tables one to hold our download information and one to house the coupon codes.


In the "file" field were not including the extension so if the download file was called file.zip, the only information entered would be file without the ".zip" extension .

Logging into the database

Here we need to create a new directory under the public directory (root) called "site" open up a text editor (I reccomend metapad) and enter the following information


Save the file as site.inc.php in the newly created site directory.
The above file is quite straighforward, it holds all your database access information and creates 2 functions: db_login() and db_logout() these functions can be called in any script which includes the site.inc.php file to log in and out of the database.

OK, we have the tables created on our database, and a way to log in and out of the database saved in a site.inc.php file in the site directory. You now need to add your products to the downloads table and your coupon codes to the coupon table - I'll let you add these, you may already have a products table in place so you can just ignore the create table and use your existing products database by changing a few variables within the script.

1  |  2  |  3  |  
Next »


Comments:

  Brille Bjarke
  Subject: "Create the Tables?" Date: Feb 21 2010 at 5:54 pm    
Okay, i'm new in all this programming but i would really like to make my own coupon codes for my bands new album.

Can anybody help me? I'm stuck at the "Create the Tables"? I know it's the first thing in this tutorial, but what document am i creating these tables in? The rest of the tutorial i seem to understand.. I use dreamweaver.

Thanks for this tutorial anyway!
  bs0d
  Subject: "SQL Database" Date: Feb 22 2010 at 12:57 am    

Brille Bjarke,

You need a SQL database. This is where the tables are created. Check your hosting- most all come with PHP and SQL. You can use phpMyAdmin as an interface to the DB, and to also execute the SQL code (this might be an easier method) starting out.
You Must be logged in or a member to comment.


Tutorial Stats

Tutorial Stats

39,358 Views
4 Total Comments
3 Rating of 5 (1 Votes)

Options

Tutorial Options

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

Articles

Related    

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



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