PHP: Questions about front-end and back-end input validation

Asked

Viewed 343 times

-2

The questions are about how to make the validations in front-end and back-end. Basically, the doubts are as follows:

  • If the front-end validation is disabled as the messages to the user?
  • Validating in javascript and PHP without being redundant?
  • What about validations of data that cannot be repeated (such as e-mail)? They should be validated via Ajax or only in the back-end?
  • Which libraries (front-end and back-end) can assist in this process?
  • Ambam, the first for safety and the second for user

  • ps: the downvote is not mine. Dear @rcs I think your question is not quite a duplicate, but it needs details, there is no one way to do it, front-end is front-end, but it would be too broad and would have many forms, it would be better to you edit and show what you have already done, there is no solution ready.

1 answer

0

For always Back End security, Front End validations are easily exceeded. For example if you implement client side validations in Javascript easily the user can disable Javacript and there is your application compromised, I would say that in Front End is more a matter of UX (user experience). Validating in the Back End is a guarantee that no matter what the user does in the Front End there will be another check! And even so I use database still use the maximum functions to avoid that in case of error in the Back End are not generated data inconsistencies, for example not allow fields with null value, Foreign Keys, length of fields, etc... As for Backend communication with Frontend depending on the architecture you are using you can for example return an array (in json if you use ajax, or php if you generate html in php) with validation messages/errors, and in case of success return in the same way the message of success to Frontend.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.