How to get the parent URL from the PHP Code

3,239 views
Skip to first unread message

Dhana

unread,
Nov 29, 2007, 10:01:30 AM11/29/07
to Professional PHP Developers

Hi,

We have designed our all html pages having 3 frames. We have used 3
php/html pages to display in the frames.
From one of my php page - We need to get the main parent's URL. We
tried using $_SERVER['PHP_SELF'], it gives the url of same page and
not the parent's url.

We need a way to get the parent url through php code - similar to
"Javascript code - window.parent.document.URL".

We need a solution either
1. To store the value got thro javascript as a php variable. OR
2. To get the parent url from the page thro php code.

Kindly tell me the solution for it

Thanks,
Dhana

The Webdevil [ 360 PSG ]

unread,
Nov 29, 2007, 11:55:04 AM11/29/07
to Professional PHP Developers
I wont start on the frames (yuk)
But a simple way could be to log each frames current URL in a unique
SESSION variable when each request is made.
something like...

$_SESSION['frame_url']['parent'] = 'http://something';
$_SESSION['frame_url']['left_side'] = 'http://somethingelse';
$_SESSION['frame_url']['main_body'] = 'http://anotherplace';

It isnt pretty but it might help you out.
I would lose the frames (uggggh) it isnt 1997 anymore.

Joel

webm...@hpiracing.com

unread,
Nov 29, 2007, 12:21:12 PM11/29/07
to Professional PHP Developers
Have you tried $_SERVER['HTTP_REFERER']?

Dhana

unread,
Nov 30, 2007, 2:03:45 AM11/30/07
to Professional PHP Developers
Thanks for ur reply

I used $_SERVER['REQUEST_URL'] ,it is working..

Thanks,
Dhana
Reply all
Reply to author
Forward
0 new messages