I would like to create a simple form with a checkbox which gives the user a possibility to view the results on a top frame of a two-frame window.
The problem is that the form variables do not transfer over to the result form if frames are used. An example:
// the form
<form NAME= 'form' method='post' action='frametest.php'>
Your name: <input type="text" name="name" > <br>
<input name="freim" type="checkbox" > Show framed
<input type="submit" value="Submit" ><br>
</form>
//frametest.php
<?php
echo "";
if (isset($freim)) {
if ($freim == "on") {
echo "<FRAMESET COLS='100%' ROWS='320,*'>";
echo "<FRAME NAME='atop' SRC='$PHP_SELF?$QUERY_STRING'>";
echo "<FRAME NAME='abottom' SRC='bottom.html'>";
echo "</FRAMESET>";
}
}
echo "Your name is <b>$name</b>";
echo "";
?>
Upon frametest.php execution:
-if "freim" != "on", the $name is displayed correctly
-if "freim" == "on", a warning (Undefined variable: name) is issued, and the contents are empty.
While writing this, I figured out that if I edit the first frame definition to explicitly send the variable
echo "<FRAME NAME='atop' SRC='$PHP_SELF?$QUERY_STRING&name=$name'>";
things start to work, but as I have 20+ fields on the form, I'd like not to use that approach (or start to use sessions), if possible.
Any ideas, anyone?