Hi, Guest ~ Login or Register

Affiliate System

Affiliate System

Listed In PHP and MySQL » Systems and Features — Viewing Full Tutorial
The following tutorial shows you how to make an affiliation system for you, or your admins/moderators, to add affiliate dynamically through a database

1. Make a database connection page. If you do now know how to, there is a tutorial in the php section.

2. Run the following query in your phpmyadmin on the database you are connecting to. CREATE TABLE `affiliate` (
`id` int(11) NOT NULL auto_increment,
`link` varchar(255) NOT NULL default '',
`name` varchar(255) NOT NULL default '',
PRIMARY KEY (`id`)
) TYPE=MyISAM AUTO_INCREMENT=3 ;


3. Now to make your admin bit, so you can add affiliates to your table.

Name this file add.php
<form name="affiliateadd" action="affiliateadd.php" method="POST">
Site Name:<br>
Name :<br>
<input name="name" type="text" id="name" style="border: 1px solid #000000; background: #f8f8f8; font-size: 10px; font-family: Tahoma;"><br>
URL:<br>
<input name="url" type="text" id="url" style="bored: 1px solid #000000;
background: #f8f8f8; font-size; 10px font-family: Tahoma;"><br>

<input type="submit" value="Submit" style="border: 1px solid #000000; background: #f8f8f8; font-size: 10px; font-family: Tahoma;">
</form>


4. Now to make the process for that, so it actually adds the data, rather than redirecting to an empty page that does nothing... Please also change "connect.php" to your connection page. Save this as affiliateadd.php
<?
include("connect.php");

$name = $_POST['name'];
$url = $_POST['url'];

$sql = "INSERT INTO affiliate (id, name, link) VALUES ('NULL',
'$name','$url')";

$query = mysql_query($sql) or die("Cannot query the database.<br>" . mysql_error());
echo "Affiliate Added, They will now appear on the affiliate box. Please alert Fin if you fucked up with something. ";
?>




5. Now all we need to do is display your affiliates. This is just a simple query that takes the data from your table.
Save this as whatever you want, it doesnt really matter, but it displays your affiliates. Please remember to edit the connect.php to your connection page again.
<?php
include('connect.php');
$query = "SELECT * FROM affiliate";
$result = mysql_query($query) or die('Error, query failed');
while ($row = mysql_fetch_array($result))
{
echo "<a href='".$row['link']."'>".$row['name']."</a><br>";
}
?>



6. Thats all done, now just add affiliates to your hearts content. I might write another tutorial soon on having images in your affiliates system.
Coding from the findesigns.co.uk CMS. <- lmao wtf?

Working Beta

  1. The Forums
    These are mostly functional. If you see any weird bugs, post a thread about it and an administrator will do something.
  2. Tutorial Writing
    You can now submit tutorials to the brand new management system.
  3. Tutorials Home
    View tutorials by categories and search for them here.
  4. Shoutbox
    See below. Registered users only!

Register

Newest User

Say hi to rayjo! rayjo joined on Wednesday, 3rd December.

Sponsor

Shoutbox