Disappearing $_POST Variables

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
fried
Forum Newbie
Posts: 16
Joined: Tue Sep 08, 2009 5:43 am

Disappearing $_POST Variables

Post 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.
Mark Baker
Forum Regular
Posts: 710
Joined: Thu Oct 30, 2008 6:24 pm

Re: Disappearing $_POST Variables

Post by Mark Baker »

Either embed it in your second form as a hidden field, or store it in session
fried
Forum Newbie
Posts: 16
Joined: Tue Sep 08, 2009 5:43 am

Re: Disappearing $_POST Variables

Post by fried »

Thanks, I thought of using a hidden field, but probable should start learning how to use $_SESSION.
Post Reply