Page 1 of 1
http_referrer for iframes
Posted: Sun Aug 05, 2007 11:18 am
by m2babaey
EDIT:: WE had a discussion yesterday. please refer to the 7th post (written by me) for the new question
Hi
As you may remember, i am trying to prepare something to give users a code to place on their pages to show ads. some suggested me to give them a 1*1 image so that enables me to analize their details and help me show ads. ( I know how to analize info after visitors clicked on the ads. Jus the display is a problem)
while i was thinking about this idea (using image), i thought maybe i can give them a code like:
Code: Select all
<img border="0" src="a redirect link here.php " width="1" height="1">
and aRedirecrtLinkHere.php analizes the HTTP_referrer and help me have the ads displayed. and finally redirect to an image.
If this works, how can I settup that link and if not any suggestion or idea that works?
thanks
Posted: Sun Aug 05, 2007 12:22 pm
by John Cartwright
Why do you need to redirect? Why not simply let the script determine which ad to display.
Posted: Sun Aug 05, 2007 12:29 pm
by m2babaey
ads need to be dynamic. that's like google adsense. the only difference is that i don't know js much.
can that work without redirecting?

Posted: Sun Aug 05, 2007 12:33 pm
by superdezign
Dynamic how? If you don't need to put in in-context or anything, then a simple PHP file that outputs an image based on a query string and whatever else you want would work fine.
Posted: Sun Aug 05, 2007 12:40 pm
by m2babaey
Thanks
first I want to check which site wants to display my ads. Then I search my database for that site's details like keywords. then I search my database again to find ads that meet the keywords. then the ads will be displayed.
But how to do that?
I have the database but need idea about the codes
Posted: Sun Aug 05, 2007 12:45 pm
by John Cartwright
file_get_contents() and readfile() might be of interest
Posted: Mon Aug 06, 2007 7:03 am
by m2babaey
I guess I got the solution. I give them an iframe code with a link to a php file on my site as src
The only remaining problem is that I can use http_referrer to realize from where my link has been clicked. But I need to realize where ( what domain) is asking for my php file to display the iframe. if i know that, I can analize their settings and display the ads according to their setting in my database
Posted: Mon Aug 06, 2007 8:40 am
by superdezign
You can still just make them put it in a query string.
Posted: Mon Aug 06, 2007 9:13 am
by m2babaey
You mean i give them this code:??
Code: Select all
<IFRAME SRC="http://mydomain.com/dbconnect.php" WIDTH=1 HEIGHT=1></IFRAME>
<IFRAME SRC="http://theirdomain.com/ads.php" WIDTH=1 HEIGHT=1></IFRAME>
<IFRAME SRC="http://mydomain.com/file.php" WIDTH=500 HEIGHT=110</IFRAME>
where the files are like this:
dbconnect.php:
ads.php:
file.php:
Code: Select all
<?php
mysql_query ("SELECT keyword FROM table WHERE url=$url") or die(mysql_error())'
mysql_query ("SELECT ads FROM table2 WHERE keyword =$keyword ") or die(mysql_error())'
//display selected ads
?>
Posted: Mon Aug 06, 2007 1:19 pm
by superdezign
Why are you making this so complicated...? It doesn't need to be.
Code: Select all
<img src="http://yourdomain.tld/path/to/adGenerator.php?referrer=theirdomain.tld" />
Why can't you just do that?