• home
  • Email: trainings@synapseindia.careers

Blogs

back

Email Validation:PHP

Oct 07, 2015

<?php if(isset($_POST[‘submit’])) { $email = $_POST[‘email’]; // Taking input from the user if(filter_var($email,FILTER_VALIDATE_EMAIL)) { echo "valid email"; } else { $email="Invalid EmailId"; } } //Note:filter_var() is a predefined function used to validate an email without using the concept of regular expression. ?> <html> <body> <form method=”post” action=””> <table> <tr> <td>Email</td> <td><input type=”text” name=”email”/></td> <td><font color=”red”><?php echo $email;?></font></td> </tr> <tr> <td><input type=”submit” name=”submit” value=”verify email”/></td> </tr> </table> </body> </html>

SynapseIndia (CEO: Shamit Khemka)