php - Bulk Email Validator works but not properly -


i wish either make use of freely available email validator (software, script or online service). there's work when insert more 1 email @ time 1 email verifies insert last , other email not verify. 1 email verifies. how can it?

my code:

<?php include_once('config.php'); if(isset($_post["email_verify_btn"])) {  $email = $_post["email_verify"];      if(strpos($email,"\n")) {         $text = explode("\n",$email);     } else {         $text = array($email);     }       function domain_exists($text)     {         $domain = substr(strrchr($text, "@"), 1);          $arr = @dns_get_record($domain, dns_mx);              if ($arr[0]['host'] == $domain && !empty($arr[0]['target'])) {             return $arr[0]['target'];         }     }     foreach ($text $abc) {         $domain = "";         $target = "";         $target_ip = "";          if(filter_var($abc, filter_validate_email)) {              if(domain_exists($abc)){                 $domain = substr(strrchr($abc, "@"), 1);                  $data = @dns_get_record($domain, dns_mx);                  if (is_array($data) || is_object($data)) {                      foreach ($data $key1) {                          $host = $key1['host'];                          $target = $key1['target'];                         $target_ip = gethostbyname($key1['target']);                      }                 }                 if($data) {                     $status = "email id valid";                                       }              } else {                 $status = "mx recored not exist";             }          } else {             $status = "not in syntax";         }          $c_by = 1;         $c_date = date('y-m-d h:i:s');         $c_ip = $_server['remote_addr'];          $insert = $connect->query("insert `email_verify_list`(`primary_email`,`host_name`,`target`,`target_ip`,`session`,`status`,`created_by`, `created_date`, `created_ip`) values ('$abc','$domain','$target','$target_ip','$c_date','$status','$c_by','$c_date','$c_ip')");            if($insert == 1) {             $_session['date_time'] = $c_date;         } else {             echo "<script>alert('!!!!!not successfully');</script>";                                             }                        } } ?> <!doctype html> <html>   <head> <meta http-equiv="content-type" content="text/html;charset=utf-8"/> <meta charset="utf-8"/> <title>bulk email varifier</title> <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, shrink-to-fit=no"/> <link rel="apple-touch-icon" href="pages/ico/60.png"> <link rel="apple-touch-icon" sizes="76x76" href="pages/ico/76.png"> <link rel="apple-touch-icon" sizes="120x120" href="pages/ico/120.png"> <link rel="apple-touch-icon" sizes="152x152" href="pages/ico/152.png"> <link rel="icon" type="image/x-icon" href="favicon.ico"/> <meta name="apple-mobile-web-app-capable" content="yes"> <meta name="apple-touch-fullscreen" content="yes"> <meta name="apple-mobile-web-app-status-bar-style" content="default"> <meta content="" name="description"/> <meta content="" name="author"/> <link href="assets/plugins/pace/pace-theme-flash.css" rel="stylesheet" type="text/css"/> <link href="assets/plugins/bootstrapv3/css/bootstrap.min.css" rel="stylesheet" type="text/css"/> <link href="assets/plugins/font-awesome/css/font-awesome.css" rel="stylesheet" type="text/css"/> <link href="assets/plugins/jquery-scrollbar/jquery.scrollbar.css" rel="stylesheet" type="text/css" media="screen"/> <link href="assets/plugins/switchery/css/switchery.min.css" rel="stylesheet" type="text/css" media="screen"/> <link href="pages/css/pages-icons.css" rel="stylesheet" type="text/css" /> <link class="main-stylesheet" href="pages/css/pages.css" rel="stylesheet" type="text/css"/> <!--[if lte ie 9]>     <link href="assets/plugins/codrops-dialogfx/dialog.ie.css" rel="stylesheet" type="text/css" media="screen" />     <![endif]--> </head> <body class="fixed-header ">  <div id="rootwizard" class="m-t-50">  <ul class="nav nav-tabs nav-tabs-linetriangle nav-tabs-separator nav-stack-sm"> <li class="active"> <a data-toggle="tab" href="#tab1"><span>email verify</span></a> </li> </ul>  <form  method="post" action="" >   <div class="tab-content"> <div class="tab-pane padding-20 active slide-left" id="tab1"> <div class="row row-same-height"> <div class="col-md-12"> <div class="padding-30">         <div class="row clearfix">         <div class="col-sm-3">         <div class="form-group form-group-default">         <label><font size="2">enter email&nbsp;&nbsp;&nbsp;<span class="glyphicon glyphicon-envelope"></span></font></label><br>         <textarea cols="43" rows="9" name="email_verify"  style="border-color:white;border-width:thin;padding:4pt;" multiple/></textarea><br>         </div>         </div>         </div>         <div class="row clearfix">         <div class="col-sm-3">         <button type="submit" name="email_verify_btn" class="btn btn-lg btn-info"  style="padding:11pt;width:200px;"/><span><b><font size="2">submit</font></b></span></button>         </div>         </div>  <br><br>         <div class="row clearfix">         <div class="col-sm-12">         <table width="100%" class="table ">         <tr class="success">         <th>primary email&nbsp;&nbsp;&nbsp;<span class="glyphicon glyphicon-envelope"></span></th>         <th>host name</th>         <th>target</th>         <th>target ip</th>         <th>status</th>         </tr>         <?php           $select = $connect->query("select * `email_verify_list` session='".$_session['date_time']."' order id");         while($row = $select->fetch_assoc()) {         ?>         <tr>         <td><?php echo $row['primary_email']; ?></td>         <td><?php echo $row['host_name']; ?></td>         <td><?php echo $row['target']; ?></td>         <td><?php echo $row['target_ip']; ?></td>         <td><?php echo $row['status']; ?></td>         </tr>         <?php } ?>         </table>         </div>         </div> </div> </div> </div> </div> </div> </form>  </div>    <script src="assets/plugins/pace/pace.min.js" type="text/javascript"></script> <script src="assets/plugins/jquery/jquery-1.11.1.min.js" type="text/javascript"></script> <script src="assets/plugins/modernizr.custom.js" type="text/javascript"></script> <script src="assets/plugins/jquery-ui/jquery-ui.min.js" type="text/javascript"></script> <script src="assets/plugins/bootstrapv3/js/bootstrap.min.js" type="text/javascript"></script> <script src="assets/plugins/jquery/jquery-easy.js" type="text/javascript"></script> <script src="assets/plugins/jquery-unveil/jquery.unveil.min.js" type="text/javascript"></script> <script src="assets/plugins/jquery-bez/jquery.bez.min.js"></script> <script src="assets/plugins/jquery-ios-list/jquery.ioslist.min.js" type="text/javascript"></script> <script src="assets/plugins/jquery-actual/jquery.actual.min.js"></script> <script src="assets/plugins/jquery-scrollbar/jquery.scrollbar.min.js"></script> <script type="text/javascript" src="assets/plugins/classie/classie.js"></script> <script src="assets/plugins/switchery/js/switchery.min.js" type="text/javascript"></script> <script src="assets/plugins/bootstrap3-wysihtml5/bootstrap3-wysihtml5.all.min.js"></script> <script type="text/javascript" src="assets/plugins/jquery-autonumeric/autonumeric.js"></script> <script type="text/javascript" src="assets/plugins/bootstrap-tag/bootstrap-tagsinput.min.js"></script> <script type="text/javascript" src="assets/plugins/jquery-inputmask/jquery.inputmask.min.js"></script> <script src="assets/plugins/bootstrap-form-wizard/js/jquery.bootstrap.wizard.min.js" type="text/javascript"></script> <script src="assets/plugins/jquery-validation/js/jquery.validate.min.js" type="text/javascript"></script> <script src="assets/plugins/bootstrap-datepicker/js/bootstrap-datepicker.js" type="text/javascript"></script> <script src="assets/plugins/summernote/js/summernote.min.js" type="text/javascript"></script> <script src="assets/plugins/moment/moment.min.js"></script> <script src="assets/plugins/bootstrap-daterangepicker/daterangepicker.js"></script> <script src="assets/plugins/bootstrap-timepicker/bootstrap-timepicker.min.js"></script> <script src="pages/js/pages.min.js"></script> <script src="assets/js/form_wizard.js" type="text/javascript"></script> <script src="assets/js/scripts.js" type="text/javascript"></script> <script src="assets/js/demo.js" type="text/javascript"></script> <script>          window.intercomsettings = {            app_id: "xt5z6ibr"          }; </script> </body> </html> 

i think , not using strpos function in correct way.

you can use way . because strpos return 0 value if string found @ 0 position . , return false if search string not found

also note string positions start @ 0, , not 1.

if(strpos($email,"\n")!==false) {     $text = explode("\n",$email); } else {     $text = array($email); } 

Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -