header (location, frame)? (load page in a frame on submit)

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
sebnewyork
Forum Commoner
Posts: 43
Joined: Wed Mar 17, 2004 10:20 pm

header (location, frame)? (load page in a frame on submit)

Post by sebnewyork »

Hi all

I have a form in a frame of a frame set, and on submit, I want a different page to load in another frame. I thought I should use the ususal header function, and add the frame target, like:

header ('location: myPage.php', 'rightframe');

But this is not working (althought "myPage.php" does load, but in the same frame as the form).

Somebody knows the solution?
Thanks...
User avatar
skehoe
Forum Commoner
Posts: 59
Joined: Sun Dec 22, 2002 5:57 am
Location: Denver

Post by skehoe »

Hey,

This works with iFrames and I'm assuming they work the same.

Have your form in frame 1 submit to itself and before you being output, check for any _POST or _GET data to indicate this is a form submission and not a fresh load.

If you have any form data, just pass it on to the script in the other frame via an onload attribute in the body tag. Here's an example:

Code: Select all

<?php

$type = $_GET['type'];

if (isset($_POST['submit']))
{
    $post = base64_encode(serialize($_POST));
}

?>
<html>
<head>
</head>
<?

if (isset($post))
{
?>
    <body onload="parent.parent.qresults.location.href='qresults.php?type=<?= $type ?>&query=<?= $post ?>';">
<?
}
else
{
?>
    <body onload="parent.qtype.location.href='qtype.php?type=<? echo $type; ?>';">
<?
}
.
.
.

?>
Hope that helps.

~Scott
Post Reply