[K12OSN] PHP and variables
henryhartley at westat.com
Tue Sep 9 18:42:01 UTC 2008
Doug Simpson wrote:
>> Yes. They will increment each time the page is submitted. It
>> posts to itself so it automatically reloads every time you hit
>> the submit button. The form collects the data and passes it to
>> the php portion with the form action. The form action posts back
>> to the same script. This causes the page to just reload after
>> you hit submit and it is supposed to tabulate each choice and
>> give a running total of each choice.
Then you must use a session variable to hold the values between each submission. Each time you submit the form and issue a POST (or GET), the PHP runs again. Any variables that are used only exist during that one running of the script. They go away again as soon as it's done. So, replace $chosenatotal with $_SESSION['chosenatotal'] (and the "b" version) and see what happens. You'll need session_start() at the top of your script, as well.
More information about the K12OSN