0

Can I use HTML Frames with PHP?

I presumed I can do this by..

<?php session_start(); require("auth.php"); require("do_html_header.php"); if($_SESSION['SESS_admin'] == 0) require("do_menu.php"); else require("do_menu3.php"); do_html_header(); print"<h1>Welcome ". $_SESSION['SESS_FIRST_NAME']."!</h1>"; do_menu(); ?> </body> <frameset rows="50%,50%"> <frame noresize="noresize" src="limits.php" /> <frame noresize="noresize" src="limits.php" /> </frameset> </html> 

I have put it everywhere but it seems not to show up..

Google just confused me.

Thanks in Advance :D

1
  • 3
    Frames have nothing to do with PHP really. As long as the PHP scripts output valid HTML, everything will work fine. What you are showing above (a body and a frameset element in the same document) is not valid HTML Commented Jan 5, 2011 at 3:45

2 Answers 2

5

You can use PHP with HTML framesets, but you shouldn't be outputting anything in a <body> element of a frameset page (even then it should be <noframes>, not <body>). Content goes within the individual pages contained by your <frame /> elements.

Anyway, don't use frames. PHP as a templating language is meant to help you separate components of your pages by way of includes, rendering framesets completely unnecessary in the first place.

Sign up to request clarification or add additional context in comments.

Comments

0

Yes, you can use frames. But you'll have to output the actual content in the frameset files, in your case limits.php. Beware of a few things here:

  • Starting the session in the frameset file is ok.
  • But you'll also have to session_start() in the limits.php frame content file.
  • Likewise the HTTP authentication should be performed in all frame files.
  • Do not assume that people cannot access do_menu3.php directly.

I've previously used frames for implementing a NortonCommand-clone for the web, where it's more senseful than CSS-arranging divs. However, handling jQuery is more cumbersome with frames. In regards to PHP it's as simple as treating every frame script as individual entry script.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.