Validating php code

Posted by / 26-Nov-2020 21:45

Validating php code

(note that the form method is post in the HTML form).

To make it a bit cleaner, we can trim the input to remove any extra space from the beginning and end of the form.

The server side form validations help keeping the form submission data consistent.

The validations also help in lesser server side errors.

It is also required to add server side form validation in your form processing script.

When you have fields like name or email as mandatory in the form, it should be checked in the server side script as well. Here is the sample output from that script: Note that the “Filling[]” checkbox group in the HTML form results in an array in the PHP script The rest of the fields appear as simple name-value pairs To validate mandatory fields, we just have to check the presence of the value in the $_POST array.

You can improve that class with your knowledge and make it more functional according to your needs.

If you have any kind of question to ask, comment below.

So, in the next step we will be creating a class to validate inputs in a more convenient way.

I assume that you have basic knowledge on Object Oriented Programming. Our class must prevent XSS attacks and validate inputs.

validating php code-44validating php code-20validating php code-85