Validating a form using php

You may print some message after sending mail optionally.It is very essential to have the input to your form validated before taking the form submission data for further processing.Live Demo Following is a live demo of the PHP form we will create by the end of this tutorial.states that after submission form data will be handled by the PHP script present in this file only.You cannot check for all fields with one command (because you cannot distinct between one and more empty fields).

Bad data can harm a server, steal information or even can delete a whole database.

You may opt for sending form data to a different file.

Validation for non-empty, alphabets and whitespace only The following code is added within the form So, if you try to understand how to write code for it step by step, step 1 is to declare the mail address to whom you want to send mail, step 2 is to write subject of the mail, step three is to collect data from POST so that you can write them to the body of mail, step 4 is to declare the mail id from which the mail is coming and finally sent mail with PHP mail() function.

Note: You can make web forms quickly with Simfatic Forms.

Simfatic Forms helps you to make complete, feature rich web forms and get it online quickly. This generic PHP form validator script makes it very easy to add validations to your form.

Search for validating a form using php:

validating a form using php-24

What it does is takes the data passed to the function, strips unwanted characters (extra space, tab, newline) from the beginning and end of the data using the PHP trim() function, strips any quotes escaped with slashes and passes it through htmlspecialchars().

Leave a Reply

Your email address will not be published. Required fields are marked *

One thought on “validating a form using php”