簡體   English   中英

Contact.PHP表單內部服務器錯誤

[英]Contact.PHP Form Internal Server error

我正在嘗試使用PHPMailer從我的contact.php頁面發送表單數據。 但它不能正常工作。 它顯示內部服務器錯誤。

這是我的contact.php表單代碼。 你能看出這段代碼有什么問題嗎?

<?PHP

session_start();
$errors = isset($_SESSION['errors']) ? $_SESSION['errors'] : [];
$fields = isset($_SESSION['fields']) ? $_SESSION['fields'] : [];

require_once("/home/leasingexpertzz/public_html/helpers/security.php");
?>


<!DOCTYPE html>
<html lang="en-US">
   <head>
      <title>Contact</title>
     <?PHP include "header.php"; ?>
   </head>
   <body class="size-1140">

      <!-- TOP NAV WITH LOGO -->  
      <header>
         <?PHP include "nav.php"; ?>
      </header>
      <section>
         <div id="head">
            <div class="line">
               <h1>Leasing Expertz</h1>
            </div>
         </div>
         <div id="content" class="left-align contact-page">
             <h1 class="sub-title">Reach us</h1>
            <div class="line">
               <div class="margin">
                  <div class="s-12 l-6">
                     <h2>Leasing Expertz</h2>
                     <address>
                        <p><i class="icon-home icon"></i> Plot no. P-25 1st floor, Uppal South End, Near  Eldico Mentions.</p>
                        <p><i class="icon-globe_black icon"></i> Sohna Road, Gurugram, Haryana, India</p>
                        <p><i class="icon-mail icon"></i> leasingexpertzz@gmail.com</p>
                     </address>
                     <br />
                     <h2>Social</h2>
                     <p class="fb"><a href="https://www.facebook.com/Leasing-Expertz-292379364250588/"><i class="icon-facebook icon"></i>Leasing Expertz</a></p>
                     <p class="linkedin"><a href="https://www.linkedin.com/"><i class="icon-linked_in icon"></i>Linked In</a></p>
                     <p class="twitter"><a href="https://twitter.com/"><i class="icon-twitter icon"></i>Tweeter</a></p>
                  </div>
                  <div class="s-12 l-6">
                     <h2>Write to us</h2>
                     <form class="customform" method="post" action="email.php">
                        <div class="s-12 l-7"><input name="senderEmail" placeholder="Your e-mail" title="Your e-mail" type="text" <?PHP echo isset($fields['email']) ? 'value="' . e($fields['email']) . '"' : '' ?> />
                        <?PHP if(!empty($errors)) : ?>
                         <p> <?PHP echo implode('', $errors); ?></p>
                        <?PHP endif;?>
                        </div>
                        <div class="s-12 l-7"><input name="sender" placeholder="Your name" title="Your name" type="text" <?PHP echo isset($fields['name']) ? 'value="' . e($fields['name']) . '"' : '' ?>/>
                        <?PHP if(!empty($errors)) : ?>
                        <p> <?PHP echo implode('', $errors); ?></p>
                        <?PHP endif;?>
                        </div>
                        <div class="s-12 l-7"><input name="senderPhone" placeholder="Your phone number" title="Your Phone" type="text" <?PHP echo isset($fields['phone']) ? 'value="' . e($fields['phone']) . '"' : '' ?>/>
                        <?PHP if(!empty($errors)) : ?>
                        <p> <?PHP echo implode('', $errors); ?></p>
                        <?PHP endif;?>
                        </div>
                        <div class="s-12"><textarea placeholder="Your massage" name="message" rows="5" <?PHP echo isset($fields['message']) ? e($fields['message']) : '' ?>></textarea>
                        <?PHP if(!empty($errors)) : ?>
                        <p> <?PHP echo implode('', $errors); ?></p>
                        <?PHP endif;?>
                        </div>
                        <div class="s-12 m-6 l-4"><button type="submit">Submit Button</button></div>
                     </form>
                  </div>
               </div>
            </div>
         </div>
         <!-- MAP -->   
         <div id="map-block">      
               <iframe src="https://www.google.com/maps/embed?pb=!1m18!1m12!1m3!1d3508.9917339135745!2d77.03635061456353!3d28.419506282502333!2m3!1f0!2f0!3f0!3m2!1i1024!2i768!4f13.1!3m3!1m2!1s0x390d229e71ef44dd%3A0x9931b80f30d32dd3!2sJMD+Megapolis!5e0!3m2!1sen!2sin!4v1492751226145" width="100%" height="450" frameborder="0" style="border:0" allowfullscreen></iframe>
         </div>
      </section>
      <!-- FOOTER -->   
      <footer>
         <?PHP include "footer.php"; ?>
      </footer>
      <script type="text/javascript" src="owl-carousel/owl.carousel.js"></script>   
      <script type="text/javascript">
         jQuery(document).ready(function($) {  
           $("#owl-demo").owlCarousel({
            slideSpeed : 300,
            autoPlay : true,
            navigation : false,
            pagination : false,
            singleItem:true
           });
           $("#owl-demo2").owlCarousel({
            slideSpeed : 300,
            autoPlay : true,
            navigation : false,
            pagination : true,
            singleItem:true
           });
         });   

      </script> 
   </body>
</html>

<?PHP
 unset($_SESSION['errors']);
 unset($_SESSION['fields']);
?>

下面是我為PHPMailer發送的email.php。

<?php

session_start();
require_once("/home/leasingexpertzz/public_html/PHPMailer_5.2.0/PHPMailerAutoload.php");

$errors =[];
if(isset($_POST["senderEmail"], $_POST["sender"], $_POST["senderPhone"], $_POST["message"])){

    $fields = [
        'email'=> $_POST["senderEmail"], 
        'name' => $_POST["sender"], 
        'phone' => $_POST["senderPhone"], 
        'message' => $_POST["message"]
    ];

    foreach ($fields as $field => $data) {
        if(empty($data)){
            $errors[] = 'The' . $field . 'is required.';
        }
    }

    if(empty($errors)){
        $mail = new PHPMailer();

        $mail->IsSMTP();            // set mailer to use SMTP
        $mail->Host = "localhost";  // specify main and backup server
        $mail->Port = 25;
        $mail->SMTPAuth = true;     // turn on SMTP authentication
        $mail->Username = "admin@leasingexpert.co.in";  // SMTP username
        $mail->Password = "xxxxxxxxxxx"; // SMTP password

        $mail->From = "admin@leasingexpert.co.in";
        $mail->FromName = "Leasing Expert";

        $mail->AddAddress("admin@leasingexpert.co.in");                  // name is optional

        $mail->WordWrap = 50;                                 // set word wrap to 50 characters

        $mail->IsHTML();                                  // set email format to HTML

        $mail->Subject = "Here is the subject";
        $mail->Body    = 'From: ' . $fields['name'] . '(' . $fields['email'] . ')' . $fields['phone'] . '<p>' . $fields['message'] .. '</p>';

        if($mail->Send())
        {
           header("Location: http://leasingexpert.co.in/confirmation.php");
           die();
        }
        else{
            $errors[] = 'Message could not be sent.';
        }

        header("Location: http://leasingexpert.co.in/confirmation.php");

    }

}else{
    $errors[] = 'Something went wrong.';
}

$_SESSION['errors'] = $errors;
$_SESSION['fields'] = $fields;    

?>

您應該嘗試閱讀日志,這些日志可能位於不同的位置,具體取決於您的操作系統和您正在使用的服務器(apache,nginx ...)。

你也可以使用xdebug

內部服務器錯誤消息表明編程中通常存在錯誤。

在開發時,您必須啟用錯誤登錄PHP.ini文件。

然后你可以在這里輕松找出錯誤輸入鏈接描述

暫無
暫無

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

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