+ 2
What is the effective way to validate a form?
Php form comprises of name, username, email and password. Client validation or Server validation or both? Why? And how?
4 Respostas
+ 6
Hi
As always it depends :) From your application target users, scale, design and ux...
But general answer should be: both validations.
Client side for 1st line of validation, it is fast and user friendly when he can get the message what is wrong immediately, on each field, not only after submiting whole form.
Server side: for security. This is the only real place where you can really block wrong data. Please be aware that people can omit your client validations (or even do not use your client at all). Also some data (for example if username is unique) can be checked only on server side.
+ 2
Form validation on the server side is more effective because the user cannot manipulate the scripts on this side. But for stronger security, it is highly recommended to have form validation on the client side as well.