By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,956 Members | 1,457 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,956 IT Pros & Developers. It's quick & easy.

Validation after form submitting..

P: n/a
Basically, im redesigning a form page on our website.

Currently the user submits the form, it does a few javascript checks
and either submits to the "processstuff.php" page, or gives the user a
JS error message.. where they have to go back and fill the details in.

Im trying to optimise and make this form/page as best as it can be.

Do you think it would be a better idea to continue using JS or use JS
then submit to the php page(where it checks some other details(postcode
validation) and submits, or just solely use php validation?

Im open to ideas please.

Thanks

Oct 16 '06 #1
Share this Question
Share on Google+
5 Replies


P: n/a
Rik
Advo wrote:
Basically, im redesigning a form page on our website.

Currently the user submits the form, it does a few javascript checks
and either submits to the "processstuff.php" page, or gives the user a
JS error message.. where they have to go back and fill the details in.

Im trying to optimise and make this form/page as best as it can be.

Do you think it would be a better idea to continue using JS or use JS
then submit to the php page(where it checks some other
details(postcode validation) and submits, or just solely use php
validation?
The best is always to do both:
1. JS validation will inform the user instantly that something is not OK,
and it will save him a trip to the server and back: better for the user,
less load on the server: a win-win.
2. JS validation can easily be bypassed or JS can be disabled by the user,
so always, always, check again with PHP on the server itself.

Grtz,
--
Rik Wasmus
Oct 16 '06 #2

P: n/a
>Basically, im redesigning a form page on our website.
>
Currently the user submits the form, it does a few javascript checks
and either submits to the "processstuff.php" page, or gives the user a
JS error message.. where they have to go back and fill the details in.
Remember, spammers, bots, viruses, and other nasties tend not to
use Javascript. And anyone can turn it off.
>Im trying to optimise and make this form/page as best as it can be.

Do you think it would be a better idea to continue using JS or use JS
then submit to the php page(where it checks some other details(postcode
validation) and submits, or just solely use php validation?
You *MUST* use php validation for security. Javascript is useful
for excluding users who refuse to turn it on or don't know how to
turn it on, and it can make the page a bit friendlier.
Oct 16 '06 #3

P: n/a
You can use AJAX with PHP, by AJAX make the php validation without
refreshing the page, after submitting do the validation again for
security. This is more friendly for users, and you can use php power
all the time.. (JS have a lot of bugs, use PHP cause of that)..
You can find a 5 minute tutorial at :
http://www.nurazije.co.nr/2006/10/5-...-tutorial.html

Oct 17 '06 #4

P: n/a

Gordon Burditt wrote:
Basically, im redesigning a form page on our website.

Currently the user submits the form, it does a few javascript checks
and either submits to the "processstuff.php" page, or gives the user a
JS error message.. where they have to go back and fill the details in.

Remember, spammers, bots, viruses, and other nasties tend not to
use Javascript. And anyone can turn it off.
Im trying to optimise and make this form/page as best as it can be.

Do you think it would be a better idea to continue using JS or use JS
then submit to the php page(where it checks some other details(postcode
validation) and submits, or just solely use php validation?

You *MUST* use php validation for security. Javascript is useful
for excluding users who refuse to turn it on or don't know how to
turn it on, and it can make the page a bit friendlier.
Yea i get what you mean and see why its needed really.

This is how im thinking it should go in my head:

user submits form JS checks If valid next page, if not valid go
back(msgbox), THEN send form variables to php processing page (store as
session) Perform php validation if false, return to the page and
put the session variables in the form fields so they dont need to fill
it in all again?

That about right?

Oct 17 '06 #5

P: n/a
NurAzije wrote:
You can use AJAX with PHP, by AJAX make the php validation without
refreshing the page, after submitting do the validation again for
security. This is more friendly for users, and you can use php power
all the time.. (JS have a lot of bugs, use PHP cause of that)..
You can find a 5 minute tutorial at :
http://www.nurazije.co.nr/2006/10/5-...-tutorial.html
And AJAX fails to call PHP validation if the user has JS disabled -
which is a big reason for having PHP validation in the first place!

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Oct 17 '06 #6

This discussion thread is closed

Replies have been disabled for this discussion.