Solved

Host of parent frame in PHP

Posted on 2002-06-12
1
323 Views
Last Modified: 2008-02-01
Hi,

I have one index.php as parent frame with an top.php, menu.php and an main.php

The index.php is on server A and the other pages on server B. In the page main.php I want to show the host name where index.php is, in this case server A. The reason why I want this is that there is also an index.php on server C and main.php must show in different ways, denpend if he is frame in from the index.php from server A or C. It can be done with JavaScript but can it be done with PHP?


Jeffeny
0
Comment
Question by:harryv
1 Comment
 
LVL 7

Accepted Solution

by:
axis_img earned 200 total points
ID: 7074883
Once the page is rendered, you will not be able to get the hostname from one of the pages in the frameset without using a client-side language such as javascript (which you already mentioned). Since PHP is server-side, it is already parsed by the time the frame pages are loaded, so you cannot dynamically grab this information once they are loaded.

A work-a-round for what you need would be to simply pass the hostname to the frame pages when they are loaded inside the frameset. Here is what I mean:

** index.php [on server A] **
<html>
<head>
</head>

<frameset rows="100,*,100">
  <frame src="top.php?host=<?=$_HTTP_SERVER_VARS['SERVER_NAME']?>">
  <frame src="main.php?host=<?=$_HTTP_SERVER_VARS['SERVER_NAME']?>">
  <frame src="menu.php?host=<?=$_HTTP_SERVER_VARS['SERVER_NAME']?>">
</frameset>
</html>

** END **

So basically it just passes the host in the query string to those scripts that are getting loaded in the frameset.

This is just a pseudo-example just to give you an idea of how you can pass that value to your scripts. If you are using PHP4.1 or above, you can change the $HTTP_SERVER_VARS to $_SERVER. ie: $_SERVER['SERVER_NAME'].

If this does not fully answer your question, please let me know and I will try to assist further.

Regards,
Barry
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

Both Easy and Powerful How easy is PHP? http://lmgtfy.com?q=how+easy+is+php (http://lmgtfy.com?q=how+easy+is+php)  Very easy.  It has been described as "a programming language even my grandmother can use." How powerful is PHP?  http://en.wikiped…
This article will explain how to display the first page of your Microsoft Word documents (e.g. .doc, .docx, etc...) as images in a web page programatically. I have scoured the web on a way to do this unsuccessfully. The goal is to produce something …
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to dynamically set the form action using jQuery.

759 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now