Page 1 of 1

Disappearing $_POST Variables

Posted: Sat Oct 03, 2009 7:05 am
by fried
I start with three buttons value 'red', 'green' and blue (select.php). This information is then sent via $_POST to a new file 'process.php' This information is stored in a variable $colour = $_POST ['colour'], no problem. This is then processed in a MySQL query and display all objects that are either 'red', 'green' or 'blue'.

Next I place two check boxes that I need to record checked or unchecked, I'm also using $_POST, form action = 'process.php'. again no problem.

However when this redirects back to 'process.php', the program is now looking for name = 'colour' from within the $_POST array coming from the checkboxes, obviously not finding it, it now cannot use this variable .

I'm sure there is a vary easy way to keep my $colour variable but I can't figure it out. Be patient I've only been studying PHP for a month or so.

Re: Disappearing $_POST Variables

Posted: Sat Oct 03, 2009 7:25 am
by Mark Baker
Either embed it in your second form as a hidden field, or store it in session

Re: Disappearing $_POST Variables

Posted: Sat Oct 03, 2009 7:59 am
by fried
Thanks, I thought of using a hidden field, but probable should start learning how to use $_SESSION.