|
Posted by Scott Bryce on October 11, 2007, 11:42 am
Please log in for more thread options
Chris Morris wrote:
> However, by storing the data correctly in the hidden fields, you can
> avoid having to revalidate it:
Not really.
> - serialise all the data you would put into the hidden
> fields into a single string.
> - one-way hash the data (e.g. sha1) with a secret salt.
> - place the serialised data into a hidden field, and the hash into another.
> (or add it on to the end of the serialised data in the same field)
> - when the form is submitted, recalculate the hash, and if it
> matches, unserialise the data (which you know is unchanged). If it doesn't
> match, reject the submission.
Which amounts to revalidating the data, albeit in a different manner.
> You then don't have to validate anything other than the new data and a
> single quick test for all the old data.
And you still need a way to handle a situation where the data from the
first form comes back different from the second form.
Your method is better than putting the data from the first from into
hidden fields with no way of knowing if the data had changed with the
submission of the second form. I would still prefer storing the data
from the first form on the server.
|