Solved

Host of parent frame in PHP

Posted on 2002-06-12
1
331 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
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…
The viewer will learn how to count occurrences of each item in an array.
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 …

914 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

21 Experts available now in Live!

Get 1:1 Help Now