|
Posted by Manuel Lemos on 03/22/07 04:20
Hello,
on 03/21/2007 09:59 PM Brian said the following:
> Just wondering if there is a better way of do this?
>
> I have a form that has one of those PHP anti-spam random images. If the user
> enters the incorrect
>
> number when they submit they get a error message and have to click back to
> re-enter it, the
>
> trouble is when they do all the fields on the form are now blank so they
> have to type it all in again.
>
>
>
> So I was thinking, when the user submits the form it sets a cookie with all
> the forms info,
>
> it runs the tests to make sure the number is correct, if correct then
> process the form and deletes the cookie.
>
> If it's not correct when the user clicks back put some code at the bottom of
> the form page that tests
>
> that the cookie is set and if there reads the info in and using JavaScript
> fills the form in.
>
> This is the only way I can think of, but it there a better way?
Sure. what you need to do is to present and process the form in the same
script.
I use a forms generation and processing class that comes with a plug-in
for CAPTCHA validation, which is the kind of human using validation you
are using.
The forms class takes that approach of using the same script to present
and process the form. Here is a tutorial video explaining the why and
how it works that way:
http://www.phpclasses.org/browse/video/1/package/1/section/usage.html
The form class is available here:
http://www.phpclasses.org/formgeneration
Here is a live example of the CAPTCHA validation plug-in:
http://www.meta-language.net/forms-examples.html?example=test_captcha_input
Here is the same tutorial video section about the CAPTCHA validation
plug-in:
http://www.phpclasses.org/browse/video/1/package/1/section/plugin-captcha.html
--
Regards,
Manuel Lemos
Metastorage - Data object relational mapping layer generator
http://www.metastorage.net/
PHP Classes - Free ready to use OOP components written in PHP
http://www.phpclasses.org/
[Back to original message]
|