簡體   English   中英

PHP 聯系表單提交失敗,並且沒有從以下位置返回錯誤消息:forms/contact.php

[英]PHP Contact Form submission failed and no error message returned from: forms/contact.php

我在聯系表單中遇到問題,我想在單擊發送消息按鈕時使用 php 發送郵件我收到錯誤表單提交失敗沒有錯誤

<div class="col-lg-6 mt-5 mt-lg-0" data-aos="fade-left" data-aos-delay="100">

        <form action="forms/contact.php" method="post" role="form" class="php-email-form">
          <div class="row">
            <div class="col-md-6 form-group">
              <input type="text" name="name" class="form-control" id="name" placeholder="Your Name" required>
            </div>
            <div class="col-md-6 form-group mt-3 mt-md-0">
              <input type="email" class="form-control" name="email" id="email" placeholder="Your Email" required>
            </div>
          </div>
          <div class="form-group mt-3">
            <input type="text" class="form-control" name="subject" id="subject" placeholder="Subject" required>
          </div>
          <div class="form-group mt-3">
            <textarea class="form-control" name="message" rows="5" placeholder="Message" required></textarea>
          </div>
          <div class="my-3">
            <div class="loading">Loading</div>
            <div class="error-message"></div>
            <div class="sent-message">Your message has been sent. Thank you!</div>
          </div>
          <div class="text-center"><button type="submit" name="submit" id="submit">Send Message</button></div>
        </form>

      </div>

在此處輸入圖像描述

這是我的 php 代碼,我保存在 forms 文件夾下的 contact.php 中。

<?php  error_reporting(E_ALL); ini_set('display_errors', 1);
$result = "";
$error  = "";
if(isset($_POST['submit']))
{
$name = $_POST['name']; // Get Name value from HTML Form
$email_id = $_POST['email']; // Get Email Value
     
$to = "support@globalexpresssolutions.net"; // You can change here your Email
$subject = $_POST['subject']; // This is your subject
     
require 'phpmailer/PHPMailerAutoload.php';
$mail = new PHPMailer;
//smtp settings
$mail->isSMTP(); // send as HTML
$mail->Host = "smtpout.secureserver.net"; // SMTP servers
$mail->SMTPAuth = true; // turn on SMTP authentication
$mail->Username = "************"; // Your mail
$mail->Password = '************'; // Your password mail
$mail->Port = 465; //specify SMTP Port
$mail->SMTPSecure = 'ssl\tls';                               
$mail->setFrom($email_id,$name);
$mail->addAddress('**********');
$mail->addReplyTo($email_id,$name);
$mail->isHTML(true);
$mail->Subject=$subject;
$mail->Body="
    <html>
        <body>
            <table style='width:600px;'>
                <tbody>
                    <tr>
                        <td style='width:150px'><strong>Name: </strong></td>
                        <td style='width:400px'>$name</td>
                    </tr>
                    <tr>
                        <td style='width:150px'><strong>Email ID: </strong></td>
                        <td style='width:400px'>$email_id</td>
                    </tr>
                    <tr>
                        <td style='width:150px'><strong>Message: </strong></td>
                        <td style='width:400px'>$msg</td>
                    </tr>
                </tbody>
            </table>
        </body>
    </html>
    ";;
if(!$mail->send())
{
    $error = "Something went worng. Please try again.";
}
else 
{
    $result="Thanks\t" .$name. " for contacting us.";
}

}

?>

我已將 phpmailer 文件添加到

在此處輸入圖像描述

請幫助我解決和理解問題

您的錯誤消息不是 php 錯誤。 在您的聯系人上啟用 php 錯誤。php 頁面並向我們顯示確切的錯誤。 您可以通過轉到 php.ini 文件並啟用所有錯誤來執行此操作。 另外,請暫時注釋掉您的郵件 function 以確保 php 正在獲取您的表單數據。

暫無
暫無

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

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