Sandy1;10993626 wrote:Got this basic version of the increment counter shown below to work using SESSION variable and a single submit button.
Really? You must not have shown us all of the code, then, because you're missing a call to [man]session_start/man.
Sandy1;10993626 wrote:I'm wondering if my issue all along was losing the value of the $selection variable in the hidden attribute when the submit button was clicked and the page was posted to itself?
Well yes, that was indeed the source of your problem. As I previously explained, you never attempted to use the value of that hidden attribute after the form was submitted.
Sandy1;10993626 wrote:I get an initial error "Undefined index: submit" befor the first button click because ($POST['submit']) is undefined.
You'll actually get two such errors if you start a new session, since $SESSION['counter'] won't exist either yet you still attempt to access it.
You should always check to see if external data exists before you attempt to access it. In other words, this:
code=php[/code]is not a good way to check if a variable exists; instead, you should use something like [man]isset/man or [man]empty/man.