So AJAX along with PHP is a powerful tool that can be used in forms, such as validation which is what we are doing now.So, as you can see in the above form, an email can be entered in.

code for validating email id in php-49code for validating email id in php-41

Something like this they use: But when you want to develop a php website in the best way, taking care of all little details, you should think what happens when your user does make a mistake in the email address, writing something like this: [email protected], or his_or even he writes ssdfsff (like many people do), I'm sure you would like to inform him and ask him to correct his email address, you maybe also want to check if the domain name of his email address is valid, you can't accept an email like this: [email protected]

So here is the php script I think you should use everytime you have a form with 'email address' input : Now you can use this function with the email address you want to verify as parameter, and it will return you true if it valide and false if it is not.

I use the Javascript onblur() function to validate the email address once the user clicks away from the text box.

So once the user enters in the email and clicks away from the text box, s/he will be able to know if the email address is a valid email.

To secure our form from such attacks, we need to validate the submitted form data.

All the values that go in the ‘In general, any value used in the header should be validated using the code above.When working with forms and interacting with your visitors, you may want to verify if your visitor entered an email address in the right field, and if it is valide or not.Most of people who are new to php world, just verify if the text box of the email address is filled or not, without verifying the syntax of the email address...This nice function will not know if an email exist really or not, it just verifies the syntax and the domain name, for example will not know that [email protected] not valide, but knows that [email protected] an invalid email address . When I first started programming in PHP, I found regular expressions very difficult.They were complicated, looked ugly, were hard to figure out, and there seemed to be a real lack of documentation in this area.