php验证邮箱

<?php 
if(isset($_POST['email'])){ 
    $email = $_POST['email']; 
    if(filter_var($email, FILTER_VALIDATE_EMAIL)){ 
        echo '<p>This is a valid email.<p>'; 
    }else{ 
        echo '<p>This is an invalid email.</p>'; 
    } 
} 
?> 
<form action="" method="post">
    Email: <input type="text" name="email" value=" <?php echo $_POST['email']; ?> ">
    <input type="submit" value="Check Email">
</form>

 

posted @ 2013-12-05 16:14  jshaibozhong  阅读(233)  评论(0编辑  收藏  举报