|
Remotely hosted scripts
OK you have a set of affiliate links but damn you havesites that do not allow PHP for example free hosts or you wish to create a simple scheme where links or content is displayed on other peoples sites . How do you do this , well with a bit of JavaScript and PHP , no problem.
Our basic script is based heavily on our clickbank script but we have made a few adaptations .
<?php
//change these
$server = "localhost";
$user = "username";
$password = "password";
$database = "database";
$tablename = "links";
//queries , connections to the MySQL database
$connection = mysql_connect("$server","$user","$password");
$db = mysql_select_db("$database",$connection);
//all entries
//$sql = "SELECT * FROM links";
//random entries
$sql = "SELECT * FROM links ORDER BY RAND() LIMIT 3";
$result = mysql_query($sql,$connection);
$numrows = mysql_num_rows($result);
//html output related
$clickbanktxt = "http://hop.clickbank.net/?";
//change the$ partnerid to your own ID
$partnerid = "shedboy/";
$target = "_blank";
while($row = mysql_fetch_array($result))
{
?>
document.write("<a target = '_new' href='<?php echo $clickbanktxt . $partnerid .$row[1]; ?>'><?php echo $row[2]; ?></a>");
document.write("<br>");
<?php
}
mysql_close($connection);
?>
The big change is the lines of JavaScript , we use these to outpur our links on a page . Now all we have to do is place the following line of code on the page where we want the links to appear , note this does not have to be on the same site even. Change the url in your own script.
<script language = "Javascript" src="http://tutorials.programmingsite.co.uk/remoteclick.php"></script>
|