Email Vaildation in PHP

This is simple email validation in PHP ,JavaScript  have easy to hack to  validation script and much more
.In php scripts is very secure  and safe. no one can hack this validation ,generally a PHP coding is very  secure .it accepted a valid  email only

!eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$

this code is only  accepted only valid  email address




Source Code


<?php
error_reporting(0);
if(isset($_POST['submit'])){
$email=$_POST['email'];
if($email==""){ $err="Enter the email address";}
else{
if(!eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $email)){
$err = "This is not a valid e-mail address !!!."; }
else{ $err="Valid email !!!";}
}}?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Email Validation</title>
<style type="text/css">
.email{border:2px dashed #CCC;border-radius:5px;width:400px;margin:0 auto;padding:25px; font-family:Verdana, Geneva, sans-serif;font-size:12px;}
.error{color:#D00;}
</style>
</head>
<body>
<div class="email">
<form method="post">
<p align="center" class="error"><?php echo $err; ?></p>
<p align="center">Enter your email&nbsp;&nbsp; <input type="text" name="email"></p>
<p align="center"><input type="submit" name="submit" value="Check"></p>
</form>
</div>
</body>
</html>

No comments:

Post a Comment