get remote parameters

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
target1
Forum Newbie
Posts: 1
Joined: Sat Mar 15, 2008 8:19 pm

get remote parameters

Post by target1 »

Hello i have a problem and i hope that somebody can help me.

i work on project banner manager. i have owners who get banner with this code:

a href="http://localhost/click.php?site_id=1"
img src="http://localhost/picture.php?site_id=1" alt="server not started" /a

image tag is associated with php file who generate picture with this code:

$image_path = $row[0];
$fp=fopen($image_path,'rb');
$data=fread($fp,filesize($image_path));
echo $data;

when some visitor click on banner i want to increment banner clicks in click.php but i dont know how to recognize
banner id. Banners generates random and some time visitor see ex. banner1, other visitor see banner2.
how can i get banner id's for same site, if at one moment ex. 10 visitors see same site with diferent banners.

any ideas? (sorry for my bad english)

Regards
scriptah
Forum Commoner
Posts: 27
Joined: Sat Mar 15, 2008 8:58 pm
Location: Long Island, NY

Re: get remote parameters

Post by scriptah »

Hello,

The problem roots to the fact that click.php and picture.php they both don't "talk" to each other, only to the client.
So the client is the only one that knows which banner he received and if he clicked it or not.

In your case I would create a temporary table in the database, specifying the last picture a client received (the client would be recognized by IP of course)

Code: Select all

 
client_ip picture_id
1.2.3.4 1.jpg
1.2.3.5 2.jpg
 
In picture.php you'll need to insert a row with the client ip and the banner you just displayed.

Code: Select all

 
insert into client_to_banner( client_ip, picture_id ) values( '{$_SERVER['REMOTE_ADDR']}', '{$row['picture_id']}' );
 
Then when he clicks in the banner, you can retrieve the ID of the banner he clicked by using this table.

Code: Select all

 
select picture_id from client_to_banner where client_ip = '{$_SERVER['REMOTE_ADDR']}'
/* increment the clicks on picture_id ... */
 
Post Reply