How To Make Email Validation Using PHP

In this tutorial, we are going to learn on How To Make Email Validation Using PHP. Using PHP scripts is safe and secure. It accepted a valid email only.
  1. <?php
  2.         !eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$
  3. ?>
Using this PHP script is only accept the valid email address. result Do you need to validate or verify an email address? To verify the validity of your email address simply enter your email address into the textbox provided and the validation tool will do the rest. Kindly click "Download Code" below to have this simple tool.

Directions:

First: Kindly copy this code to your HEAD section of your page.
  1. <style type="text/css">
  2. .container{
  3.         border:2px ridge #CCCCCC;
  4.         border-radius:5px;
  5.         width:400px;
  6.         margin:0 auto;
  7.         padding:25px;
  8.         font-family:Verdana, Geneva, sans-serif;
  9.         font-size:12px;
  10.         float:left;
  11. }
  12. .error{
  13.         color:chocolate;
  14.         font-weight:bold;
  15. }
  16. .text_style {
  17.         font-size: 15px;
  18.         color: blue;
  19.         font-weight: bold;
  20. }
  21. .text_box {
  22.         text-indent: 10px;
  23.         width: 200px;
  24.         height: 30px;
  25.         border: 2px solid #D9D9D9;
  26.         font-size: 15px;
  27. }
  28. .btn_style {
  29.         width: 100px;
  30.         float: right;
  31.         margin-right: 26px;
  32.         font-size: 15px;
  33.         background: rgba(0,0,0,.6);
  34.         color: #fff;
  35.         cursor: pointer;
  36.         border-radius: 5px;
  37.         height: 30px;
  38. }
  39. </style>
Second: You have to copy this shortcode to the BODY section of your page.
  1. <?php
  2. error_reporting(0);
  3. if(isset($_POST['enter'])){
  4. $email=$_POST['email'];
  5. if($email==""){ $err="* Enter your email address...";}
  6. else{
  7. if(!eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $email)){
  8. $err = "* Email Address Syntax is not correct..."; }
  9. else{ $err="* Email Address Syntax is correct...";}
  10. }}?>
  11. <div class="container">
  12.         <form method="post">
  13.                 <p align="center" class="error">
  14.                         <?php echo $err; ?>
  15.                 </p>
  16.                 <p align="center">
  17.                         <span class="text_style">Enter your email</span>
  18.                         <input type="text" class="text_box" name="email" placeholder="Email Address...">
  19.                 </p>
  20.                 <p align="center">
  21.                         <input type="submit" class="btn_style" name="enter" value="Check">
  22.                 </p>
  23.         </form>
  24. </div>
Share us your thoughts and comments below. Thank you so much for dropping by and reading this tutorial post. For more updates, don’t hesitate and feel free to visit this website more often and please share this with your friends or email me at [email protected]. Practice Coding. Thank you very much.

Add new comment