Building a Simple Affiliate System in PHP/MySQL - Building The Database (
Page 2 of 6 )
First, we want to build the database. This is a pretty basic database designed to keep track of affiliates and their traffic/sales to your website. We'll need two tables.
CREATE TABLE affiliates (
ID int(10) NOT NULL auto_increment,
username varchar(50) NOT NULL default '',
password varchar(32) NOT NULL default '',
site varchar(255) NOT NULL default '',
email varchar(255) NOT NULL default '',
akey varchar(32) NOT NULL default '',
ptype varchar(32) NOT NULL default '0',
pemail varchar(255) NOT NULL default '',
address text NOT NULL,
PRIMARY KEY (ID),
UNIQUE KEY akey (akey)
) TYPE=MyISAM AUTO_INCREMENT=1;
CREATE TABLE affstats (
ID int(10) NOT NULL auto_increment,
akey varchar(32) NOT NULL default '',
type tinyint(4) NOT NULL default '0',
status tinyint(4) NOT NULL default '0',
ip varchar(150) NOT NULL default '',
date datetime NOT NULL,
OrderID varchar(32) NOT NULL default '',
price varchar(32) NOT NULL default '',
PRIMARY KEY (ID)
) TYPE=MyISAM AUTO_INCREMENT=1;
Setting Your Settings
Your settings will be stored in a file called "config.php." We'll keep this simple.
<?
$sitename = ""; // site name
$siteurl = ""; // site url
$redirecturl = ""; // redirect url
$affpay = ""; // affiliate payout amount
$aduser = ""; // admin username
$adpass = ""; // admin password
$dbhost = ""; // database hostname
$dbuser = ""; // database username
$dbpassword = ""; // database password
$dbname = ""; // database name
?>
These settings are important and should be set before we start. The variables are broken down as follows:
$sitename = The name of your website
$siteurl = The URL to the affiliate script as it is
installed on your site
$redirecturl = The URL where visitors are redirected to after
coming to your site using an affiliate link.
$affpay = The amount affiliates are paid for each sale.
If you set it to 5.00, then affiliates
will get paid 5.00 for each sale.
$aduser = Your management login username
$adpass = Your management login password
$dbhost = Your database host (usually localhost)
$dbuser = Your database username
$dbpassword = Your database password
$dbname = The name of your database
| | Discuss Building a Simple Affiliate System in PHP/MySQL | | | | | | | When I saw the headline, I was quite anxious to read this article. Unfortunately,... | | | | | | We are sorry to hear that you found the article disappointing. I am contacting the... | | | | | | Well, The article is about building a simple affiliate system. Which is what it... | | | | | | Hi. DevShed is all about open source programming. This article explores the... | | | | | | This article was entirely appropriate. I mean if it was about inventory tracking... | | | | | | Hello All,
A big thanks to the author for taking time to write this... | | | | | | There was a slight bad there when they inserted the article into the system... | | | | | | Thanks! I'll let ya know how I make out!
MrsDelley | | | | | | and what is this:
Parse error: parse error, unexpected ';' in... | | | | | | sorry i am blind today, although it is an error.
for those who may ask this Q... | | | | | | one more Qurestion i have;
What is this: <img src="/affiliates/sale.php">.... | | | | | | I keep getting this error message:
Warning: mysql_query(): supplied argument is... | | | | | | hi, first of all thanks for sharing this nice script. it seems to do exactly what i... | | | | | | scrap my last comment, i should be logging into manage.php not accesscotrol.php.... | | | | | | Its a very nice script.:)
Some notes from the comments that could be updated to... | | | | | | I get the same exact error message. Could someone shed some light on the solution... | | | | | | I get alot of these errors:
Warning: mysql_query(): supplied argument is not a... | | | | | | Hi There,
this script in common.php:
list($pending_total) = mysql_fetch_row(... | | | | | | I have gone through each page and created all the files. Needless to say, there is a... | | | | | | You access your MySQL database through a program called PHPMyAdmin. It should be... | | | | | | Hi to the Poster above,
I did eventually figure out how to upload the tables as... | | | | | | Hi, I'm have 2 problems at the moment with the system, although I see it will be... | | | | | | These scripts are broken and make a mess. | | | | | | have some one this script to work perfectly?
my yahoo messenger is edifice28 | | | | | | >>> Post your comment now! | | | | | |
|
 |