注意:未定义的变量:错误

时间:2017-03-01 18:37:34

标签: php

首先感谢任何可以提供帮助的人。其次,我已经做了大量的研究,仍然无法找到解决我的困境的答案。

我目前从PHP代码中收到以下错误:

注意:未定义的变量:第18行的/Applications/MAMP/htdocs/NEW-Site/AndersonPennaBelmontPool/Current/_scripts/emailConfig.php中的消息

注意:未定义的变量:第49行/Applications/MAMP/htdocs/NEW-Site/AndersonPennaBelmontPool/Current/_scripts/emailConfig.php中的标题

警告:无法修改标题信息 - 已在/ Applications / MAMP / htdocs / NEW中发送的标题(输出从/Applications/MAMP/htdocs/NEW-Site/AndersonPennaBelmontPool/Current/_scripts/emailConfig.php:14开始) -Site / AndersonPennaBelmontPool / Current / _scripts / email.php在第15行

我用回波测试了变量,并且要做的变量似乎已经设置好了。

以下是供参考的代码。

表格代码:

<?php
$page = "Contact";
?>
<?php include ('includes/header.php'); ?>

<!-- Content Starts here --> 
      <div class="section group">
        <div class="col span_2_of_3">
          <h1>Comment Form</h1>
          <p>Please provide any comments you have on this website or the project using the fields below.</p>
          <p><img src="images/required.png" alt="Required"> indicates required field </p>
          <div class="form_wrapper">
            <form name="form_inquiry" id="form_inquiry" action="_scripts/email.php" method="post">
              <label for="name">Name:</label>
              <input name="name" type="text" id="name" placeholder="First and Last Name" autofocus required >
              <br>
              <br>
              <label for="email">Email:</label>
              <input name="email" type="email" id="email" placeholder="Email Address" required >
              <br>
              <br>
              <label for="street_address">Full Street Address:</label>
              <input name="street_address" type="text" id="street_address" placeholder="Full Street Address (Street, City, State, Zipcode)" required >
              <br>
              <br>
              <label for="state">Phone Number:</label>
              <input name="phone" type="tel" id="phone" placeholder="Phone Number: ###-###-####" pattern="\d{3}[\-]\d{3}[\-]\d{4}" required >
              <br>
              <br>
              <label for="comment">Comment:</label>
              <textarea name="comment" rows="5"id="comment" placeholder="Enter Comment" ></textarea>
              <br>
              <br>
              <label>Check the box below for Website Update Notification.</label>
              <input type="checkbox" name="update_notification[]" id="update_notification" value="Yes" style="width: 20px; height:20px">
              <br>
              <br>
              <div class="g-recaptcha" data-sitekey=""></div>
              <br>
              <br>
              <input name="send" type="submit" id="send" value="Send">
            </form>
          </div>
          <br>
          <br>
          <p>For information on existing aquatic programs at the Belmont Temporary Pool, click <a href="http://www.longbeach.gov/park/recreation-programs/aquatics/pools/belmont-pool/" target="_blank">here</a>.</p>
          <p>The DEIR Public Comment Period (April 13, 2016 to June 16, 2016) has expired. Comments on the project received after June 16, 2016 will be addressed only as they pertain to subsequent project development milestones and/or permitting processes.</p>
        </div>
        <script type="text/javascript"> 
         // ref: http://diveintohtml5.org/detect.html
          function supports_input_placeholder()
         {
            var i = document.createElement('input'); 
            return 'placeholder' in i;
         }
            if(!supports_input_placeholder()) {  
            var fields = document.getElementsByTagName('INPUT');
            for(var i=0; i < fields.length; i++) {
              if(fields[i].hasAttribute('placeholder')) {
                  fields[i].defaultValue = fields[i].getAttribute('placeholder');
                  fields[i].onfocus = function() { if(this.value == this.defaultValue) this.value = ''; }
                  fields[i].onblur = function() { if(this.value == '') this.value = this.defaultValue; }
               }
              }
            }
        </script>
        <div class="col span_1_of_3">
          <h1>Contact</h1>
          <h3>Dino D’Emilia, PE<br>
            Consultant Project Manager<br>
            <a href="mailto:ddemilia@andpen.com" title="Email" target="_blank">ddemilia@andpen.com</a> </h3>
        </div>
      </div>

 <!-- Content Ends Here -->  

<?php include ('includes/footer.php'); ?>

以下是表单操作脚本:

<?php   

    session_start();

    if(isset($_POST['send'])){
        $url = 'https://www.google.com/recaptcha/api/siteverify';
        $privatekey = '';
        $response = file_get_contents($url."?secret=".$privatekey."&response=".$_POST['g-recaptcha-response']."&remoteip=".$_SERVER['REMOTE_ADDR']);
        $data = json_decode($response); 

        if(isset($data->success) AND $data->success==true){         
            //Insert code for True result
            include ('emailConfig.php');
            //redirect the user to this page
            header('Location: ../email_sent.php');
        }else{
            //Insert code for False result
            header('Location: ../email_sent_error.php');
        }

    }
?>

以下是电子邮件配置文件:

<?php
// multiple recipients
/*$to  = 'aidan@example.com' . ', '; // note the comma
$to .= 'wez@example.com';*/

//single recipient

$to = 'rgarcia@mbimedia.com';

// subject
$subject =  'Comment from Belmont Pool Website';

// Test Print
echo $_POST['name'];
echo $_POST['email'];

// message
$message .= 'From: ' . $_POST['name'] . "\r\n";
$message .= 'Email: ' . $_POST['email'] . "\r\n";
$message .= 'Comment: ' . "\r\n" . $_POST['comment'] . "\r\n";
$message .= "\r\n";
$message .= 'Full Street Address: ' . $_POST['street_address'] . "\r\n";
$message .= 'Phone: ' . $_POST['phone'] . "\r\n";
$message .= "\r\n";

foreach($_POST['update_notification'] as $update_notification){
    if(isset($update_notification)){
        $message .= 'Website Update Notification: Yes' . "\r\n";
    } else{
        $message .= 'Website Update Notification: No' . "\r\n";
    }
}

$message .= "\r\n";
$message .= '* You received this message because ' . $_POST['name'] . ' submitted a comment.' . "\r\n";
$message .= "\r\n";
$message .= 'Regards,' . "\r\n";
$message .= 'System Administrator';

/*
//To send HTML mail, the Content-type header must be set
$headers  = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
*/

// Additional headers
// $headers .= 'To: Mary <mary@example.com>, Kelly <kelly@example.com>' . "\r\n";

$headers .= 'From: ' . $_POST['email'] . "\r\n";
$headers .= 'Cc: ' . "\r\n";

// $headers .= 'Bcc: birthdaycheck@example.com' . "\r\n";

// Mail it to Tolar
mail($to, $subject, $message, $headers);
/*
//Start custom message to user
$userTo = $_POST['email'];
$userSubject = 'Tolar Feedback';
$userMessage = 
'
<html>
<head>
<title>Tolar Comments/Feedback</title>
</head>
<body>
<h3>Hi ' . $_POST['fname'] . ' ' . $_POST['lname'] . ',</h3>
<p>This is an automatic message in response to your feedback. Please do not respond to this email. We will contact you within 2-3 business days.</p>
<p>Thank you,<br>
The SR-91 Team</p>
</body>
</html>
';

//To send HTML mail, the Content-type header must be set
$userHeaders  = 'MIME-Version: 1.0' . "\r\n";
$userHeaders .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";

//additional header
$userHeaders .= 'From: noreply@mbimedia.com';

//mail it to the user
mail($userTo, $userSubject, $userMessage, $userHeaders);
*/
?>

任何帮助将不胜感激。这也是一个时间敏感的,并提前感谢您的任何帮助。

0 个答案:

没有答案