|
Posted by ELINTPimp on 04/13/07 21:07
On Apr 11, 3:38 pm, "Jerim79" <m...@hotmail.com> wrote:
> For the moment, the biggest question before me, is how to make it so
> that the user doesn't have to recheck each line if the form fails to
> verify. Here is an idea. What if upon submission, I were to exclude
> any questions from the form that were already answered correctly? Such
> that the first time through, it prints out all questions. Upon
> submission it verifies each variable. If all the variables contain
> data, then we move on to the next page. If a variable contains no
> data, then we repost the question to the user. Within the "IF
> ($error>0)" I could wrap each occurrence of a question with an IF
> statement to see if data for that variable has already been entered.
> If not, then it prints the question. If so, it skips on to the next
> IF.
> Does isset() maintain its status
> throughout all submissions? (As far as I know, PHP can only hold one
> form at a time. If you submit another form, then the values of that
> form overwrite the previous form.)
You're correct about having to retain the state of those variables
that were answered "correctly". You can do this like you initially
suggested, passing it back and forth from server to client each time
using $_POST or $_GET using hidden values in the form or using a
cookie on the client...but another way to do it, to save network
resources and the like, is to save it on the server. If you're using
a database, I suggest using transactions. You can "store" the
variables in the transaction until the user get's them all "correct"
and then commit the transaction. That would also give you the added
benefit of using rollbacks if the transaction fails at a later part.
Another way is to use sessions and to save those variables deemed
"correct" as a session variable. That way, the only thing that you
would need to send back and forth from the server to client would be
the session ID.
[Back to original message]
|