错误未定义变量和一些数据插入数据库但不是所有数据

时间:2017-06-23 04:51:50

标签: javascript php html css ajax

这是错误

  

注意:未定义的变量:域名   第59行的C:\ wamp64 \ www \ email_verify \ index.php

     

注意:未定义的变量:第59行的C:\ wamp64 \ www \ email_verify \ index.php中的目标

     

注意:未定义的变量:第59行的C:\ wamp64 \ www \ email_verify \ index.php中的target_ip

代码是

<?php
include_once('config.php');
if(isset($_POST["email_verify_btn"])) {

        $email = $_POST["email_verify"];

        if(strpos($email,"\n")) {

        $text = explode("\n",$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 as $abc) {


                    if(domain_exists($abc)){
                        $domain = substr(strrchr($fetch_email, "@"), 1);

                        $data = @dns_get_record($domain, DNS_MX);

                            if($data) {
                            $status = "email id is valid";                      
                        }

                        if (is_array($data) || is_object($data)) {

                            foreach ($data as $key1) {

                                $host = $key1['host'];
                                $target = $key1['target'];
                                $target_ip = gethostbyname($key1['target']);

                            }

                        }



                    } else {
                      $status = "mx recored not exist";
                    }

                    $c_by = 1;
                    $c_date = date('Y-m-d H:i:s');
                    $c_ip = $_SERVER['REMOTE_ADDR'];

                    $insert = $connect->query("INSERT INTO `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_ip','$status','$c_by','$c_date','$c_ip')");

                    if($insert) {
                        $_SESSION['date_time'] = $c_date;
                        echo "<script>alert('successfully');</script>";
                    } 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 YOUR 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 * from `email_verify_list` where session='".$_SESSION['date_time']."' order by 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>

我该如何解决,请将此更新代码发送给我

1 个答案:

答案 0 :(得分:1)

<?php
include_once('config.php');
if(isset($_POST["email_verify_btn"])) {
   $email = $_POST["email_verify"];
   if(strpos($email,"\n")) {
   $text = explode("\n",$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 as $abc) {
  $domain = "";
  $target = "";
  $target_ip = "";
  if(domain_exists($abc)){
        $domain = substr(strrchr($fetch_email, "@"), 1);
        $data = @dns_get_record($domain, DNS_MX);
        if($data) {
           $status = "email id is valid";                      
        }
        if (is_array($data) || is_object($data)) {
           foreach ($data as $key1) {
              $host = $key1['host'];
              $target = $key1['target'];
              $target_ip = gethostbyname($key1['target']);
           }
        }
   } else {
        $status = "mx recored not exist";
   }
   $c_by = 1;
   $c_date = date('Y-m-d H:i:s');
   $c_ip = $_SERVER['REMOTE_ADDR'];
   $insert = $connect->query("INSERT INTO `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_ip','$status','$c_by','$c_date','$c_ip')");
      if($insert) {
         $_SESSION['date_time'] = $c_date;
         echo "<script>alert('successfully');</script>";
      } else {
         echo "<script>alert('!!!!!not successfully');</script>";                                    
      }                   
   }
}
?>

变量未定义,因为它们超出了范围。如果你想使用它们,你应该在同一级别范围内声明它们。之后,您可以在insert查询中使用它。

希望这会对你有所帮助。