Solved

Host of parent frame in PHP

Posted on 2002-06-12
1
351 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 Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit (http://en.wikipedia.org/wiki/PHPUnit) and similar technologies have enjoyed wide adoption, making it possib…
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

829 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