http_referrer for iframes

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
m2babaey
Forum Contributor
Posts: 364
Joined: Sun May 20, 2007 9:26 am

http_referrer for iframes

Post 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
Last edited by m2babaey on Mon Aug 06, 2007 7:45 am, edited 2 times in total.
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

Why do you need to redirect? Why not simply let the script determine which ad to display.
m2babaey
Forum Contributor
Posts: 364
Joined: Sun May 20, 2007 9:26 am

Post 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? :?
User avatar
superdezign
DevNet Master
Posts: 4135
Joined: Sat Jan 20, 2007 11:06 pm

Post 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.
m2babaey
Forum Contributor
Posts: 364
Joined: Sun May 20, 2007 9:26 am

Post 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
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

file_get_contents() and readfile() might be of interest
m2babaey
Forum Contributor
Posts: 364
Joined: Sun May 20, 2007 9:26 am

Post 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
User avatar
superdezign
DevNet Master
Posts: 4135
Joined: Sat Jan 20, 2007 11:06 pm

Post by superdezign »

You can still just make them put it in a query string.
m2babaey
Forum Contributor
Posts: 364
Joined: Sun May 20, 2007 9:26 am

Post 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:

Code: Select all

connects to my mysql database
ads.php:

Code: Select all

<?php
$url="theirdomain.com";
?>
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
?>
User avatar
superdezign
DevNet Master
Posts: 4135
Joined: Sat Jan 20, 2007 11:06 pm

Post 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?
Post Reply