doumeng06063991 2018-06-18 23:51
浏览 111

PHP X-Mailer不发送所有字段

I am by no means a developer. Self-taught, but can usually wing it enough to make things happen. Working on company website for boss, and having trouble with the form. Regardless of how I try to define the PHP variable, SOME are not sending the input value to the e-mail. I'm sure I'm missing something simple, thank you in advance for your help! This is what's not showing:

Website: Average Monthly Volume: Preferred Contact Method:

Here is what I have so far:

HTML FORM:

<div class="product-screens2">
    <div style="padding:200px">
        <div class="form">
          <div id="sendmessage">Your message has been sent. Thank you!</div>
          <div id="errormessage">Please retry.</div>
          <form action="form-email" method="post" role="form" class="contactForm">
            <div class="form-row">
              <div class="form-group col-lg-6">
                <input type="text" name="name" class="form-control" id="name" placeholder="Your Name" data-rule="minlen:4" data-msg="Please enter at least 4 chars" />
                <div class="validation"></div>
              </div>
                <div class="form-group col-lg-6">
              <input type="email" class="form-control" name="email" id="email" placeholder="Your Email" data-rule="email" data-msg="Please enter a valid email" />
                <div class="validation"></div>
              </div>
              <div class="form-group col-lg-6">
                <input type="text" class="form-control" name="subject" id="subject" placeholder="Business Name" />
               </div>
                <div class="form-group col-lg-6">
                <input type="text" name="name" class="form-control" id="business_site" placeholder="Business Website"  />
                 </div>
           <div class="form-group col-lg-6">
             <input type="text" class="form-control" name="name" id="avgvolume" placeholder="Average Monthly Volume" />
              </div>
                <div class="form-group col-lg-6">
             <input type="text" class="form-control" name="name" id="contactmethod" placeholder="Preferred Contact Method" />
              </div>
            </div>
            <div class="form-group">
              <textarea class="form-control" name="message" rows="5" data-rule="required" data-msg="Please write something for us" placeholder="Brief Description of Goods or Services Sold"></textarea>
              <div class="validation"></div>
            </div>
            <div class="text-center"><button type="submit" title="Send Message">SUBMIT</button></div>
          </form>

      </div></div>
</div>

PHP MAILER SCRIPT

<?php

/***************** Configuration *****************/

// Enter your email, where you want to receive the messages.
$contact_email_to = "Support@XXXXX.com";

// Subject prefix
$contact_subject_prefix = "Message From XXXXX Website: ";

// Name too short error text
$contact_error_name = "Name is too short or empty!";

// Email invalid error text
$contact_error_email = "Please enter a valid email!";

// Subject too short error text
$contact_error_subject = "Subject is too short or empty!";

// Message too short error text
$contact_error_message = "Too short message! Please enter something.";



/********** Do not edit from the below line ***********/

if(!isset($_SERVER['HTTP_X_REQUESTED_WITH']) AND strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) != 'xmlhttprequest') {
  die('Sorry Request must be Ajax POST');
}

if(isset($_POST)) {

  $name = filter_var($_POST["name"], FILTER_SANITIZE_STRING);
  $email = filter_var($_POST["email"], FILTER_SANITIZE_EMAIL);
  $subject = filter_var($_POST["subject"], FILTER_SANITIZE_STRING);
  $message = filter_var($_POST["message"], FILTER_SANITIZE_STRING);
  $business_site = $_POST["business_site"];
  $avgvolume = $_POST["avgvolume"];
  $contactmethod = $_POST["contactmethod"];


  if(strlen($name)<4){
    die($contact_error_name);
  }

  if(!filter_var($email, FILTER_VALIDATE_EMAIL)){
    die($contact_error_email);
  }

  if(strlen($message)<3){
    die($contact_error_subject);
  }

  if(strlen($message)<3){
    die($contact_error_message);
  }

  if(!isset($contact_email_from)) {
    $contact_email_from = "contactform@" . @preg_replace('/^www\./','', $_SERVER['SERVER_NAME']);
  }

  $sendemail = mail($contact_email_to, $contact_subject_prefix . $subject,
    "Name: $name" . PHP_EOL .
    "Reply-To: $email" . PHP_EOL .
    "Business: $subject" . PHP_EOL .
    "Website: $business_site" . PHP_EOL .
    "Average Monthly Volume: $avgvolume" . PHP_EOL .
    "Preferred Contact Method: $contactmethod" . PHP_EOL .
    "Business Description: $message" . PHP_EOL .
    "X-Mailer: PHP/" . phpversion()
  );

  if( $sendemail ) {
    echo 'OK';
  } else {
    echo 'Could not send mail! Please check your PHP mail configuration.';
  }
}
?>
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥20 西门子S7-Graph,S7-300,梯形图
    • ¥50 用易语言http 访问不了网页
    • ¥50 safari浏览器fetch提交数据后数据丢失问题
    • ¥15 matlab不知道怎么改,求解答!!
    • ¥15 永磁直线电机的电流环pi调不出来
    • ¥15 用stata实现聚类的代码
    • ¥15 请问paddlehub能支持移动端开发吗?在Android studio上该如何部署?
    • ¥20 docker里部署springboot项目,访问不到扬声器
    • ¥15 netty整合springboot之后自动重连失效
    • ¥15 悬赏!微信开发者工具报错,求帮改