Hey, I've got what has become an extremely frustrating problem with $_Post variables. I'll give examples of code rather than the actual segments to save time and confusion. On one page I'm doing this:
<? echo "<form name='form' action='page.php' method='post'>
<input type='hidden' name='slot' value=".$i.">
</form>";
?>
The $i is an index in a while loop (I'm echoing this simple form several times). The form itself is submitted with a bit a javascript.
All's well at this point, the form is submitted properly and takes me to another page, where I need to use that "slot" value to do some other junk. However, when I try to do this:
<? echo "<form name='another_form' action='another_page.php' method='post'>
<input type='hidden' name='slot_num' value=".$_POST['slot'].">
//SOME OTHER HIDDEN VARS
</form>";
?>
or this...
<? echo "<form name='another_form' action='another_page.php' method='post'>
<input type='hidden' name='slot_num' value=";
echo $_POST['slot'];
echo ">
//SOME OTHER HIDDEN VARS
</form>";
?>
or this...
<? //TOP OF PAGE
$slots = $_POST['slot'];
?>
<? //FURTHER DOWN
<? echo "<form name='another_form' action='another_page.php' method='post'>
<input type='hidden' name='slot_num' value=".$slots.">
//SOME OTHER HIDDEN VARS
</form>";
?>
...all I get is an Undefined index: slot etc.. etc... error, and source of the php document just has blank space. Funny thing is, if I simply do this:
echo $_POST['slot'];
at the top of the page, it prints out the value from the previous page just fine, however, if I view the source, it still shows an Undefined index error instead of the value. I KNOW the value is getting passed because it prints, but I can't use it for anything else because if I try to include it in my php code, it just displays an error and gives a blank value!
I've also tried using $HTTP_POST_VARS['slots'] with the same result... I am at wits end after several hours of experimentation... any advice?