2016-01-13 110 views
0

沒有信息這是我的html代碼:充分利用聯繫表

<form id="main-contact-form" name="contact-form" method="post" action="php/sendemail.php"> 

      <div class="row wow fadeInUp" data-wow-duration="1000ms" data-wow-delay="300ms"> 
       <div class="col-sm-6"> 
       <div class="form-group"> 
        <input type="text" name="name" class="form-control" placeholder="Nombre Completo" required=""> 
       </div> 
       </div> 
       <div class="col-sm-6"> 
       <div class="form-group"> 
        <input type="email" name="email" class="form-control" placeholder="Correo Electronico" required=""> 
       </div> 
       </div> 
      </div> 
      <div class="form-group"> 
       <input type="text" name="phone" class="form-control" placeholder="Numero de telefono" required=""> 
      </div> 
      <div class="form-group"> 
       <input type="text" name="section" class="form-control" placeholder="Grado & Sección" required=""> 
      </div> 
      <div class="form-group"> 
       <input type="text" name="subject" class="form-control" placeholder="Subjeto" required=""> 
      </div> 

      <div class="form-group"> 
       <textarea name="txt" id="message" class="form-control" rows="4" placeholder="Mensaje" required=""></textarea> 
      </div>       
      <div class="form-group"> 
       <button type="submit" name="submit12" class="btn-submit">Enviar ahora</button> 
      </div> 
      </form> 

,這是我的PHP一個:

<?php 

$subjectm = $_POST['subject']; 
$txt = $_POST['txt']; 
$section = $_POST['section']; 
$email = $_POST['email']; 
$name = $_POST['name']; 
$phone = $_POST['phone']; 


$to = "[email protected]"; 


$subject = "".$subjectm." | Solicitud de Soporte - Colegio La Victoria"; 

$headers = "From: " . $email . "\r\n"; 
$headers .= "Reply-To: ". $email . "\r\n"; 
$headers .= "CC: [email protected]\r\n"; 
$headers .= "MIME-Version: 1.0\r\n"; 
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n"; 

$message = " 
<html> 
<head> 
<title>".$subjectm." | Solicitud de Soporte - Colegio La Victoria</title> 
</head> 
<body> 

<h3><b>Nombre:</b> </h3><h5>".$name."</h5>\n \n \n</br> 
<h3><b>Grado y sección: </h3><h5></b>".$section." <b>\n \n \n</br></h5> 
<h3><b>Correo Electronico:</b> </h3><h5>".$email."\n \n \n</br></h5> 
<h3><b>Numero de Telefono:</b> </h3><h5>".$phone."\n \n \n</br></h5> 
<h3><b>Mensaje: </b></h3><h5>".$txt."\n \n \n</br></h5> 

<h2>Este es un mensaje automatizado, favor de no contestar al mismo.</h2> 
</body> 
</html> 
"; 


mail($to, $subject, $message, $headers); 


?> 

所以,問題是:當我點擊發送,我得到電子郵件,但它的空(從index.php獲取信息sendemail.php),我嘗試了一切,但我無法修復它。

這是消息即時得到我的郵箱:

農佈雷: 格拉多Ÿsección: 郵報Electronico: NÚMERO德Telefono: Mensaje: 埃斯特ES聯合國mensaje automatizado,有利於德沒有contestar人MISMO 。

(Obviusly其空)

+0

您是否獲得所有字段?或者只有你無法得到的消息部分? – cweitat

+0

你有兩條$消息。它正在覆蓋另一個。 – cweitat

+0

@cweitat我解決了你在說但仍然無法工作。我沒有得到任何信息在網站上輸入。 – Roberth

回答

0

我無法找到你的代碼的確切問題,但我發現成功由兩個文件合併成一個如下面的代碼所示。

<?php if (!empty($_POST)) 
     { 

     $subjectm = $_POST['subject']; 
     $message = $_POST['message']; 
     $section = $_POST['section']; 
     $email = $_POST['email']; 
     $name = $_POST['name']; 
     $phone = $_POST['phone']; 

     $to = "[email protected]"; 

     $subject = "".$subjectm." | Solicitud de Soporte - Colegio La Victoria"; 

     $headers = "From: " . $email . "\r\n"; 
     $headers .= "Reply-To: ". $email . "\r\n"; 
     $headers .= "CC: [email protected]\r\n"; 
     $headers .= "MIME-Version: 1.0\r\n"; 
     $headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n"; 

     $message = " 
     <html> 
     <head> 
     <title>".$subjectm." | Solicitud de Soporte - Colegio La Victoria</title> 
     </head> 
     <body> 

     <h3><b>Nombre:</b> </h3><h5>".$name."</h5>\n \n \n</br> 
     <h3><b>Grado y sección: </h3><h5></b>".$section." <b>\n \n \n</br></h5> 
     <h3><b>Correo Electronico:</b> </h3><h5>".$email."\n \n \n</br></h5> 
     <h3><b>Numero de Telefono:</b> </h3><h5>".$phone."\n \n \n</br></h5> 
     <h3><b>Mensaje: </b></h3><h5>".$message."\n \n \n</br></h5> 

     <h2>Este es un mensaje automatizado, favor de no contestar al mismo.</h2> 
     </body> 
     </html> 
     "; 


     mail($to, $subject, $message, $headers); 

     } 

     ?> 

<form id="main-contact-form" name="contact-form" method="post" action=""> 

<div class="row wow fadeInUp" data-wow-duration="1000ms" data-wow-delay="300ms"> 
    <div class="col-sm-6"> 
    <div class="form-group"> 
     <input type="text" name="name" class="form-control" placeholder="Nombre Completo" required=""> 
    </div> 
    </div> 
    <div class="col-sm-6"> 
    <div class="form-group"> 
     <input type="email" name="email" class="form-control" placeholder="Correo Electronico" required=""> 
    </div> 
    </div> 
</div> 
<div class="form-group"> 
    <input type="text" name="phone" class="form-control" placeholder="Numero de telefono" required=""> 
</div> 
<div class="form-group"> 
    <input type="text" name="section" class="form-control" placeholder="Grado & Sección" required=""> 
</div> 
<div class="form-group"> 
    <input type="text" name="subject" class="form-control" placeholder="Subjeto" required=""> 
</div> 

<div class="form-group"> 
    <textarea name="message" id="message" class="form-control" rows="4" placeholder="Mensaje" required=""></textarea> 
</div>       
<div class="form-group"> 
    <button type="submit" name="submit" class="btn-submit">Enviar ahora</button> 
</div> 
</form> 
+0

你確定嗎?他的'$ message' var在第二個'$ message'聲明中,它將'$ _POST ['message']'的值放入'$ message'中。換句話說:'$ a =「test1」; $ a =「test2 $ a」; echo $ a; //輸出 - >「test2 test1」' – ryebread

+0

是的你是對的。我編輯了我的答案。 – Beans

0

我猜測它與你如何聲明頭文件有關。嘗試運行這個,因爲它有點乾淨,並且可以在我的開發機器上運行:

<?php 

$subjectm = $_POST['subject']; 
$message = $_POST['message']; 
$section = $_POST['section']; 
$email = $_POST['email']; 
$name = $_POST['name']; 
$phone = $_POST['phone']; 

$to = "[email protected]"; 
$subject = "$subjectm | Solicitud de Soporte - Colegio La Victoria"; 

$headers = array(); 
$headers[] = "MIME-Version: 1.0"; 
$headers[] = "Content-type: text/html; charset=iso-8859-1"; 
$headers[] = "From: {$email}"; 
$headers[] = "CC: {$to}"; 
$headers[] = "Reply-To: {$email}"; 
$headers[] = "Subject: {$subject}"; 
$headers[] = "X-Mailer: PHP/".phpversion(); 

$message = " 
<html> 
<head> 
<title>$subject</title> 
</head> 
<body> 

<h3><b>Nombre:</b> </h3><h5>$name</h5>\n \n \n</br> 
<h3><b>Grado y sección: </h3><h5></b>$section<b>\n \n \n</br></h5> 
<h3><b>Correo Electronico:</b> </h3><h5>$email \n \n \n</br></h5> 
<h3><b>Numero de Telefono:</b> </h3><h5>$phone \n \n \n</br></h5> 
<h3><b>Mensaje: </b></h3><h5>$message \n \n \n</br></h5> 

<h2>Este es un mensaje automatizado, favor de no contestar al mismo.</h2> 
</body> 
</html>"; 

mail($to, $subject, $message, implode("\r\n", $headers)); 

?> 
+0

仍然不適合我。你使用什麼PHP版本? – Roberth

+0

現在不在它前面,但我很確定我的測試機器正在運行5.6.11。 – ryebread

+0

在消息傳輸過程中,知道你的error.log說了些什麼(如果有的話)以及你的mail.log的輸出可能會有幫助。 – ryebread