Hi,
I'm trying to write an advertising script. Each advertising client has their own URL. These urls are displayed on a number of my pages. The clients will buy a number of times they're page is visitied. Basically it's a pay per click program. When someone clicks their banner, they are sent through a redirect script to the appropriate site.
Here's the problem. I need to be able to track the number of times each page is clicked on, and stop displaying when it gets to the number they paid for. I couldn't find a script for this, or any sample code to get me started.
Can anyone lead me in the right direction?
Thanks,
Josh
Redirect and Track Stats
Moderator: General Moderators
-
d3ad1ysp0rk
- Forum Donator
- Posts: 1661
- Joined: Mon Oct 20, 2003 8:31 pm
- Location: Maine, USA
uhh, you'd need to add 1 to the current database files for their "clicks" variable or w/e, such as:
and then have a function on the other site that echos a random link (one that hasnt been clicked the max amount of times) or something..
[edited]
Code: Select all
<?php
//connect to DB
$id = $_GET['id'];
$linksql = "SELECT `link` FROM `table` WHERE `id` = '$id'";
$link = mysql_result(mysql_query($linksql);
$sql = "UPDATE `table` SET `clicks` = `clicks`+1 WHERE `id` = '$id'";
mysql_query($sql) or die("Error: Could not Update Clicks.");
header("Location:$link");
?>[edited]
Last edited by d3ad1ysp0rk on Sat Jan 03, 2004 6:48 pm, edited 2 times in total.
Just adding:
(You can add 'clicks' using a single update clause rather than the posted fetch-add-update way & added the id as you need to know what link was clicked.)
Code: Select all
$sql = "UPDATE table SET clicks = clicks+1 where id = $id";-
d3ad1ysp0rk
- Forum Donator
- Posts: 1661
- Joined: Mon Oct 20, 2003 8:31 pm
- Location: Maine, USA
I actually haven't even begun coding anything yet... I'm still in the planning phase. You're saying I should create a database with all my customers, and update it as the clicks come in.
That's not the problem, Most of my ads are on servers other than my own. The only way I could think of to accomplish this would be to redirect to somewhere on my site, with an ID field, then update my database from my own server... Am I correct in thinking this?
Also, I need this fairly quickly, and time is money to me. Does anyone know if there's a script for sale that would offer this functionality? or is it simple enough that a semi-newbie could put it together in reasonable time?
Thanks,
Josh
That's not the problem, Most of my ads are on servers other than my own. The only way I could think of to accomplish this would be to redirect to somewhere on my site, with an ID field, then update my database from my own server... Am I correct in thinking this?
Also, I need this fairly quickly, and time is money to me. Does anyone know if there's a script for sale that would offer this functionality? or is it simple enough that a semi-newbie could put it together in reasonable time?
Thanks,
Josh
-
Paddy
- Forum Contributor
- Posts: 244
- Joined: Wed Jun 11, 2003 8:16 pm
- Location: Hobart, Tas, Aussie
- Contact:
You were correct in thinking that. They click, redirects to your site, updates the DB, redirects to the link if they have enough 'click credit' else redirects to another site.
It is rather easy, I would suggest you either write it yourself or put this in the help wanted section.
By the way, do you have control of these other sites your banners are on? If not someone could change the URL to just go to the site required and bypass your database facility and therefore never have to pay for clicks. Just a side not for you to think about if you are in that situation.
It is rather easy, I would suggest you either write it yourself or put this in the help wanted section.
By the way, do you have control of these other sites your banners are on? If not someone could change the URL to just go to the site required and bypass your database facility and therefore never have to pay for clicks. Just a side not for you to think about if you are in that situation.