Page 1 of 1

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

Posted: Wed Dec 15, 2004 11:26 am
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...

Posted: Wed Dec 22, 2004 2:28 pm
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