Solved

Host of parent frame in PHP

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

Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

Question has a verified solution.

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

Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

831 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