473,466 Members | 1,360 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Check click

I have a page and a sponsor. Every time a user click on a banner from our
sponsor their webpage is opened. I'd like to reward these users, but how to
check who clicked on a banner. I can't do anything on sponsor's webpage?

Thanks for helping,
Boris ©avc

Jul 17 '05 #1
3 2172
Boris ©avc wrote:
I have a page and a sponsor. Every time a user click on a banner from our
sponsor their webpage is opened. I'd like to reward these users, but how to
check who clicked on a banner. I can't do anything on sponsor's webpage?


Instead of
<a href="http://sponsor.com/"><img src="sponsor.png"/></a>

do
<a href="sponsor.php?url=http://sponsor.com/"><img src="sponsor.png"/></a>

and in sponsor.php redirect to the sponsor page after updating your user
information, for example:

<?php //sponsor.php
$user_id = 0; // ir your code get it from where you have it stored
$sql = "update user set clicks=clicks+1 where id=$user_id";
// do sql

header('Location: ' . $_GET['url']);
// some browsers may not follow the redirect
exit('Redirected <a href="' . $_GET['url'] . '">here</a>');
?>

--
USENET would be a better place if everybody read: : mail address :
http://www.catb.org/~esr/faqs/smart-questions.html : is valid for :
http://www.netmeister.org/news/learn2quote2.html : "text/plain" :
http://www.expita.com/nomime.html : to 10K bytes :
Jul 17 '05 #2
Regarding this well-known quote, often attributed to Pedro Graca's famous
"26 May 2004 11:10:46 GMT" speech:
Boris ©avc wrote:
I have a page and a sponsor. Every time a user click on a banner from our
sponsor their webpage is opened. I'd like to reward these users, but how to
check who clicked on a banner. I can't do anything on sponsor's webpage?


Instead of
<a href="http://sponsor.com/"><img src="sponsor.png"/></a>

do
<a href="sponsor.php?url=http://sponsor.com/"><img src="sponsor.png"/></a>

and in sponsor.php redirect to the sponsor page after updating your user
information, for example:

<?php //sponsor.php
$user_id = 0; // ir your code get it from where you have it stored
$sql = "update user set clicks=clicks+1 where id=$user_id";
// do sql

header('Location: ' . $_GET['url']);
// some browsers may not follow the redirect
exit('Redirected <a href="' . $_GET['url'] . '">here</a>');
?>


For a more robust solution, I'd recommend having some sort of table linking
individual banners or sponsors to their sites, be it an external MySQL
table or a simple hash array. Limiting the script to a finite number of
approved URLs it can redirect to will stop cross-site scripting attacks and
other illegitimate uses of your site's script.

http://us3.php.net/manual/en/language.types.array.php
<?php
// Remember! Nothing comes before the ?php tag, or the
// redirect won't work!

$my_home_page = "http://www.somewhereorother.com";
$banners = array(
"example1" => "http://www.example.com/",
"example2" => "http://www.example.com/superwebvalues",
"phpnet" => "http://www.php.net/"
);
// Set up a hash array with codenames => URLs
// (See http://us3.php.net/manual/en/language.types.array.php )
if ($banners[$_GET['banner']]) { // if the banner they requested exists...
// (Do some MySQL or something HERE to increment the codename's counter)
// ...

// Then redirect to the proper page
// (See http://us3.php.net/manual/en/function.header.php )
header("Location: " . $banners[$_GET['banner']]);
}
else {
// If there isn't a banner with that codename,
// just redirect to the homepage
header("Location: " . $my_home_page);
}

?>

--
-- Rudy Fleminger
-- sp@mmers.and.evil.ones.will.bow-down-to.us
(put "Hey!" in the Subject line for priority processing!)
-- http://www.pixelsaredead.com
Jul 17 '05 #3
Regarding this well-known quote, often attributed to FLEB's famous "Wed, 26
May 2004 15:39:20 -0400" speech:
Regarding this well-known quote, often attributed to Pedro Graca's famous
"26 May 2004 11:10:46 GMT" speech:
Boris ©avc wrote:
I have a page and a sponsor. Every time a user click on a banner from our
sponsor their webpage is opened. I'd like to reward these users, but how to
check who clicked on a banner. I can't do anything on sponsor's webpage?
For a more robust solution, I'd recommend having some sort of table linking
individual banners or sponsors to their sites, be it an external MySQL
table or a simple hash array. Limiting the script to a finite number of
approved URLs it can redirect to will stop cross-site scripting attacks and
other illegitimate uses of your site's script.

http://us3.php.net/manual/en/language.types.array.php
<?php
// Remember! Nothing comes before the ?php tag, or the
// redirect won't work!

$my_home_page = "http://www.somewhereorother.com";
$banners = array(
"example1" => "http://www.example.com/",
"example2" => "http://www.example.com/superwebvalues",
"phpnet" => "http://www.php.net/"
);
// Set up a hash array with codenames => URLs
// (See http://us3.php.net/manual/en/language.types.array.php )
if ($banners[$_GET['banner']]) { // if the banner they requested exists...
// (Do some MySQL or something HERE to increment the codename's counter)
// ...

// Then redirect to the proper page
// (See http://us3.php.net/manual/en/function.header.php )
header("Location: " . $banners[$_GET['banner']]);
}
else {
// If there isn't a banner with that codename,
// just redirect to the homepage
header("Location: " . $my_home_page);
}

?>


I forgot something. To use this script, assuming it's called "banner.php"
access it as:

banner.php?banner=codename

Where "codename" is the codename in the first column.

--
-- Rudy Fleminger
-- sp@mmers.and.evil.ones.will.bow-down-to.us
(put "Hey!" in the Subject line for priority processing!)
-- http://www.pixelsaredead.com
Jul 17 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Dakanali | last post by:
I have a previous form which user search if there is a domain name. Give the domain name and in xml send the data from domainName=rewuest.form("domainname") to the specify url which is below and i...
7
by: Tony Johnson | last post by:
Can you make a check box very big? It seems like when you drag it bigger the little check is still the same size. Thank you, *** Sent via Developersdex http://www.developersdex.com ***...
1
by: simonmarkjones | last post by:
Hi i've just started using check boxes on my form. When the check box is clicked i want to test a condition is met (in my database i'm only allowing certain users to click the check box to void...
7
by: Neil | last post by:
I have a check box on a form that's bound to a function that returns a True/False value. When the user clicks on the check box, I run some code through the MouseDown event. Everything works fine. ...
4
by: Shawn | last post by:
Hi. I have a ToolBar with a couple of ToolBarButtons. On postback after clicking on of the buttons Page_Load is called first then the ToolBarButton's click event is called. Is there anyway for...
6
by: Mike | last post by:
I am just beginning with VB and had been using a crippled version of VB 6.0 which works fine except there's limited information resouces with it. So, like a good scout, I got a learning edition of...
1
by: scprosportsman | last post by:
Please help guys, i am trying to set up a database here at work and im fairly new to access in terms of writing functions and queries and stuff. I have 2 different places on my design that will...
4
by: peter | last post by:
I've come across a weird difference between the behaviour of the Tkinter checkbox in Windows and Linux. The issue became apparent in some code I wrote to display an image in a fixed size canvas...
2
by: Daniel | last post by:
HI I have a requirement to check for .net 2 framework on ym app running as well as checking if a particular directx version is intalled, can anyone give any tips or pointers where i could find a...
4
by: ghjk | last post by:
I have check boxes in my php page. when I click som check boxes and click submit button I want to set read only to check boxes values. This is my code. But it is not working. <td><input value="1"...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.