Home arrow MySQL arrow Page 4 - Building a Simple Affiliate System in PHP/MySQL

Your Index Page - MySQL

Setting up an affiliate system on your website can be very lucrative. While there are a lot of details involved, it need not be overly complicated. This article walks you through the steps of creating and setting up a basic affiliate system.

TABLE OF CONTENTS:
  1. Building a Simple Affiliate System in PHP/MySQL
  2. Building The Database
  3. Being Common
  4. Your Index Page
  5. Letting Affiliates Log in
  6. Adding Affiliate Code to Your Site
By: Roger Stringer
Rating: starstarstarstarstar / 58
November 10, 2005

print this article
SEARCH DEV SHED

TOOLS YOU CAN USE

advertisement

Create a page called "index.php." This page serves as your introduction to your affiliate site.

 <?
  include("common.php");
  include("header.php");
 ?>
  <P>Sign up here to be one of our affiliates. Earn $<?=number_format($affpay,2)?> for each sale you
  generate.</P>
  <ul>
  <li><a href='account.php'>Login To Your Account</a>
  <li><a href='join.php'>Sign Up For An Account</a>
  </ul>
 <?
  include("footer.php");
 ?>

Letting Affiliates Join

One of the first things you need to do is let your affiliates sign up.

Create a file called "join.php":

<?
  include("common.php");
  include("header.php");

  $step = isset($_POST['step']) ? $_POST['step'] : 1;
  switch ($step){
    case '2':
      // add affiliate to the DB
      $aid = AffiliateAdd();
      if( $aid ){
        echo "Thank you for signing up. You can now log in to your account<br>";
        echo "<a href='account.php'>Login Here</a><br/>";
      }
      break;
    default:
?>
      <table>
      <form method="POST">
      <input type='hidden' name='step' value='2'>
<?
      foreach($affiliateForm as $field=>$info){
        echo "<tr>";
        if( !empty($info[0]) ){
          echo "<td valign=top>{$info[0]}</td>";
        }
        echo "<td valign=top>";
        switch($info[1]){
          case "hidden":
            echo "<input type='hidden' name='{$field}' value='{$info[2]}'>";
            break;
          case "password":
            echo "<input type='password' name='{$field}' value=''>";
            break;
          case "text":
            echo "<input type='text' name='{$field}' value='{$info[2]}'>";
            break;
          case "textarea":
            echo "<textarea name='{$field}' rows=5 cols=25>{$info[2]}</textarea>";
            break;
          case "select":
            $info[2] = explode("|",$info[2]);
            echo "<select name='{$field}'>";
            foreach($info[2] as $k=>$v){
              echo "<option>{$v}</option>";
            }
            echo "</select>";
            break;
      }
      echo "</td>";
      echo "</tr>";
    }
?>
    <tr>
      <td colspan=2><input type='submit' value='Save'></td>
    </tr>
    </form>
    </table>
<?
    break; 
  }
  include("footer.php");
?>



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

blog comments powered by Disqus
escort Bursa Bursa escort Antalya eskort
   

MYSQL ARTICLES

- Oracle Unveils MySQL 5.6
- MySQL Vulnerabilities Threaten Databases
- MySQL Cloud Options Expand with Google Cloud...
- MySQL 5.6 Prepped to Handle Demanding Web Use
- ScaleBase Service Virtualizes MySQL Databases
- Oracle Unveils MySQL Conversion Tools
- Akiban Opens Database Software for MySQL Use...
- Oracle Fixes MySQL Bug
- MySQL Databases Vulnerable to Password Hack
- MySQL: Overview of the ALTER TABLE Statement
- MySQL: How to Use the GRANT Statement
- MySQL: Creating, Listing, and Removing Datab...
- MySQL: Create, Show, and Describe Database T...
- MySQL Data and Table Types
- McAfee Releases Audit Plugin for MySQL Users

Developer Shed Affiliates

 


Dev Shed Tutorial Topics: