PDA

View Full Version : Losing Variable's Contents across Form Processing?


gorilla1
11-09-2002, 02:01 PM
I have a counter set in a form like so:

<input type="hidden" name="Pass" value="<?php $Pass ?>" />

I then process it on submit like so:

$Pass = $HTTP_POST_VARS['Pass'];

and increment it:

$Pass = $Pass + 1;

This was based on logic that I had in an asp script. However, in php, the value of $pass is not held - it appears to be null each time through, and then it equals 1 each time after being incremented. Is there a way to hold a variable's value across the form processing?

G

mordred
11-09-2002, 02:22 PM
Well, you have to print the value of $Pass to the HTML output. A quick look at the HTML source code should illustrate my point:


<input type="hidden" name="Pass" value="<?php echo $Pass; ?>" />

gorilla1
11-09-2002, 03:18 PM
Mordred, Yep, that is correct, thanks. - G