簡體   English   中英

按下按鈕時不會提交聯系表格

[英]Contact form won't submit on button press

努力讓我的聯系表格發送。 我已經粘貼了下面的代碼

當我填寫表格並推送發送時,沒有任何反應。 我試過使用按鈕而不是輸入提交,但仍然沒有任何作用。 我之前有過這樣的表格,但現在我無法發送。 有什么線索嗎?

<form id="contact-form" method="post" action="process.php">
  <div class="row">
    <div class="col-md-6 col-lg-6 col-sm-12 col-xs-12">
      <div class="form-group" id="name-field">
        <div class="form-input">
          <input type="text" class="form-control" id="form-name" name="form-name" placeholder="Full Name">
        </div>
      </div>
    </div>
    <div class="col-md-6 col-lg-6 col-sm-12 col-xs-12">
      <div class="form-group" id="email-field">
        <div class="form-input">
          <input type="email" class="form-control" id="form-email" name="form-email" placeholder="Email address">
        </div>
      </div>
    </div>
  </div>
  <div class="row">
    <div class="col-md-6 col-lg-6 col-sm-12 col-xs-12">
      <div class="form-group" id="name-field">
        <div class="form-input">
          <input type="text" class="form-control" id="form-address" name="form-address" placeholder="Address of the works">
        </div>
      </div>
    </div>
    <div class="col-md-6 col-lg-6 col-sm-12 col-xs-12">
      <div class="form-group" id="email-field">
        <div class="form-input">
          <input type="text" class="form-control" id="form-phone" name="form-phone" placeholder="Phone number">
        </div>
      </div>
    </div>
  </div>
  <div class="row">
    <div class="col-md-12 col-lg-12 col-sm-12 col-xs-12">
      <div class="form-group" id="phone-field">
        <div class="form-input">
          <input type="text" class="form-control" id="form-subject" name="form-subject" placeholder="Description of the works required">
        </div>
      </div>
    </div>
  </div>
  <div class="row">
    <div class="col-md-12 col-lg-12 col-sm-12 col-xs-12">
      <div class="form-group" id="message-field">
        <div class="form-input">
          <textarea class="form-control" rows="6" id="form-message" name="form-message" placeholder="Further Information"></textarea>
        </div>
      </div>
    </div>
  </div>
  <div class="row">
    <div class="col-md-12 col-lg-12 col-sm-12 col-xs-12">
      <div class="form-group">
        <input type="submit" value="SEND FORM" />
      </div>
    </div>
  </div>
</form>
<?php
           {
          $to = "info@blank.co.uk";
          $subject = "Contact Page from ";
          $headers  = "From: A T L <noreply@blank.co.uk>\r\n";
         $headers .= "Reply-To: noreply@blank.co.uk\r\n";
    $headers .= "Return-Path: noreply@blank.co.uk\r\n";
      $headers .= "MIME-Version: 1.0\r\n";
    $headers .= "Content-type: text/html; charset: utf8\r\n";
      $name = filter_input(INPUT_POST, 'form-name');
     $email = filter_input(INPUT_POST, 'form-email');   
       $address = filter_input(INPUT_POST, 'form-address');
       $telephone = filter_input(INPUT_POST, 'form-phone');
      $theirSub = filter_input(INPUT_POST, 'form-subject');
      $message = filter_input(INPUT_POST, 'form-message');

     $message = 
     "<span style='font-weight: bold;'>Name: </span>"."<br />".$name."<br />"."<br />".
     "<span style='font-weight: bold;'>Email: </span>"."<br />".$email."<br />"."<br />".
     "<span style='font-weight: bold;'>Address: </span>"."<br />".$address."<br />"."<br />".
     "<span style='font-weight: bold;'>Telephone: </span>"."<br />".$telephone."<br />"."<br />".
     "<span style='font-weight: bold;'>Email: </span>"."<br />".$email."<br />"."<br />".
     "<span style='font-weight: bold;'>Subject: </span>"."<br />".$theirSub."<br />"."<br />".
     "<span style='font-weight: bold;'>Message: </span>"."<br />".$message."<br />"."<br />";

     mail($to, $subject,"We have received a message via the online form at www.blank.co.uk<br /><br />" . 
     $message, $headers);
     echo "Your message was successfully sent. Please <a href='contact.php'>click here</a> to return to the site.";
      ?>
       <?php  }
       ?>

$message 變量被使用了兩次...一次是從表單接收數據,然后你覆蓋它? 您可能希望為此使用不同的變量。 我改為 $msg。

此外,您有很多不必要的 php 標簽。 也許嘗試一些像這樣更清潔的東西來開始:

<?php
$to = "info@blank.co.uk";
$subject = "Contact Page from ";
$headers  = "From: A T L <noreply@blank.co.uk>\r\n";
$headers .= "Reply-To: noreply@blank.co.uk\r\n";
$headers .= "Return-Path: noreply@blank.co.uk\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset: utf8\r\n";
$name = filter_input(INPUT_POST, 'form-name');
$email = filter_input(INPUT_POST, 'form-email');   
$address = filter_input(INPUT_POST, 'form-address');
$telephone = filter_input(INPUT_POST, 'form-phone');
$theirSub = filter_input(INPUT_POST, 'form-subject');
$msg = filter_input(INPUT_POST, 'form-message');

$message = 
"<span style='font-weight: bold;'>Name: </span>"."<br />".$name."<br />"."<br />".
"<span style='font-weight: bold;'>Email: </span>"."<br />".$email."<br />"."<br />".
"<span style='font-weight: bold;'>Address: </span>"."<br />".$address."<br />"."<br />".
"<span style='font-weight: bold;'>Telephone: </span>"."<br />".$telephone."<br />"."<br />".
"<span style='font-weight: bold;'>Email: </span>"."<br />".$email."<br />"."<br />".
"<span style='font-weight: bold;'>Subject: </span>"."<br />".$theirSub."<br />"."<br />".
"<span style='font-weight: bold;'>Message: </span>"."<br />".$msg."<br />"."<br />";

mail($to, $subject,"We have received a message via the online form at www.blank.co.uk<br /><br />" . $message, $headers);
echo "Your message was successfully sent. Please <a href='contact.php'>click here</a> to return to the site.";
?>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM