SQL PHP HTML ASP JavaScript articles and free scripts to download

Email validation within a form in PHP

In an input field we can verify the email address entered is in correct format or not using PHP eregi function. This is a part of php form validation we do for other entries to check proper formatted data is entered by the user or not. You can enter any email address and check it is a valid address or not. Please not that we are not checking the validation or existence of the URL or the service provider. We are only checking / validating the format of the email address. This code can be used as a part of the other entered data validation used. You can read the php form validation by visiting the tutorial here. Here is the demo of the email validation. Test this validation by entering any formatted email address. You will get a message based on the result of validation.

Demo of Email Validation

Here is the code of this validation in PHP.
if(isset($todo) and $todo=="test"){

if (!eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $email)){ 
echo "<center>Invalid email</center>";
echo "<center>Valid Email</center>";}

PHP filter FILTER_VALIDATE_EMAIL is used to check email in PHP 5.2
Read how we can use the same code for email validation using Ajax & PHP

good 22-05-2013
its interestiing..!!
Post Comment This is for short comments only. Use the forum for more discussions.
Email( not to be displayed)Privacy Policy
1+2=This is to prevent automatic submission by spammers. Please enter the result of the sum as asked

Join Our Email List
For Email Newsletters you can trust
HTML . MySQL. PHP. JavaScript. ASP. Photoshop. Articles. FORUM Contact us

©2000-2014 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer