MySQL
  Home arrow MySQL arrow Page 2 - Building a Simple Affiliate System in PHP/MySQL
Dev Shed Forums  
Administration  
AJAX  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Smartphone Development  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Mobile Linux  
App Generation ROI  
IBM® developerWorks  
Forums Sitemap  
E-Commerce Hosting  
Linux Web Hosting  
Managed Hosting  
Small Business Hosting  
VPS Hosting  
Weekly Newsletter

 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid  
Request Media Kit
Contact Us  
Site Map  
Privacy Policy  
Support  
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
Google.com  
MYSQL

Building a Simple Affiliate System in PHP/MySQL
By: Roger Stringer
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: starstarstarstarstar / 47
    2005-11-10


    Table of Contents:
  • Building a Simple Affiliate System in PHP/MySQL
  • Building The Database
  • Being Common
  • Your Index Page
  • Letting Affiliates Log in
  • Adding Affiliate Code to Your Site

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      error-file:tidyout.log Del.ici.ous error-file:tidyout.log Digg
      error-file:tidyout.log Blink error-file:tidyout.log Simpy
      error-file:tidyout.log Google error-file:tidyout.log Spurl
      error-file:tidyout.log Y! MyWeb error-file:tidyout.log Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article

     
     
    ADVERTISEMENT


    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



     
     
    >>> More MySQL Articles          >>> More By Roger Stringer
     

       

    MYSQL ARTICLES

    - MySQL Security Tips
    - Designing a MySQL Database: Tips and Techniq...
    - The Three Most Important MySQL Queries
    - Null and Empty Strings
    - MySQL Server Tuning Tips and Tricks
    - MySQL Query Optimizations and Schema Design
    - MySQL Benchmarking Tools and Utilities
    - MySQL Benchmarking Concepts and Strategies
    - Take Some Load off MySQL with MemCached
    - MySQL Table Prefix Changer Tool in PHP
    - Using the SIGNAL Statement for Error Handling
    - Error Handling Examples
    - Error Handling
    - Completing a Search Engine with MySQL and PH...
    - Paginating Result Sets for a Search Engine B...





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 5 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek