Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Mar 24th, 2005, 7:54 PM   #1
bigi
Newbie
 
Join Date: Mar 2005
Posts: 3
Rep Power: 0 bigi is on a distinguished road
Random banner rotator problem

Hi,
I'm trying to write a banner rotator script in PHP, one that doesn't use SSI to call or include() in a php script or anything.
In other words, the way I want it to work is basically like WebAdverts back then (for perl), where you would include a static HTML on a regular HTML page like:
<a href="http://www.mysite.com/bannerlink.php?pageid=123&whateverelse">
<img src="http://www.mysite.com/bannerdisplay.php?pageid=123&whateverelse">
</a>
However, I now need a way to correspond the clicking of a certain banner correctly with the banner that was displayed.
I'm thinking about using cookies to achieve this. but I would still need to include some sort of page ID that is different for every page that displays the banner, would I? is there any way I can have one piece of static code on all pages? also, even if I use page IDs, if a user goes to a page, then open a new window and go to that page again and a new banner is displayed, clicking the banner on the first window would still redirect to the wrong link, wouldn't it?
What is a good solution to this problem?
Please don't suggest the use of SSI or include() because the situation doesn't allow for it.

Thanks!
bigi is offline   Reply With Quote
Old Mar 25th, 2005, 9:40 AM   #2
codetaino
Programmer
 
codetaino's Avatar
 
Join Date: Jan 2005
Location: Bayamon, Puerto Rico
Posts: 71
Rep Power: 4 codetaino is on a distinguished road
Thinking really quick.... two similars solutions come to my mind first one is have a script like bannerlink.php that redirect you using an id like you are doing on the example. Inside the script maybe an array or a switch that will select the correct redirection. (i dunno if you are going to enter this hardcoding or you are goint to prepare an page to insert them.) for the image i think 2 possible solutions first one is having a specific folder with the images name corresponding to the id of the link like img src="http://www.mysite.com/images/123.jpg, the otherone im not sure... but i think is possible... php can be used to generate other file types using the headers of the files and other stuff... if this is possible then you can use the same tecnique of the urls to the images like in your example.

-codetaino


PS: Sorry about my errors, english is not my primary language

EDIT:

take a look of this code i found.. i played with it and managed to create a link with an image loaded dynamicly so... i think is posible just to have 2 files with correspondent ids for image and link and sending that id to load correspondents correctly without using includes or ssi...

[PHP]<?
//Just grab some general image info
$img = "matrix.gif";
$path = "matrix.gif";
$imageInfo = GetImagesize($img);

if ( $imageInfo[2] == 1 ) {
//it's a gif
$file = fread(fopen($path, "r"), filesize($path));

$fileHeader = "image/gif";
Header("Content-Type: ".$fileHeader);
echo $file;
fclose($file);
}
?> [/PHP]
note: this code will act as a gif, i used matrix.gif as an example but you can use any gif u like (including animated... mine was) to test it i did something like this...
<a href="http://codetaino.is-a-geek.com">
<img src="http://codetaino.is-a-geek.com/testcode/img2.php">
</a>
-codetaino
__________________
"God bless u all" :)

Last edited by codetaino; Mar 25th, 2005 at 10:36 AM.
codetaino is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 3:05 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC