简体   繁体   English

从联系表获取任何信息

[英]Getting no info from Contact Form

This is my html code: 这是我的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>  

and this is my php one: 这是我的PHP之一:

<?php

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


$to = "soporte@colegiolavictoria.holixgaming.com";


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

$headers = "From: " . $email . "\r\n";
$headers .= "Reply-To: ". $email . "\r\n";
$headers .= "CC: soporte@colegiolavictoria.holixgaming.com\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);


?>

so, the problem is: when i hit the send button, i get the email but its empty (is getting info from index.php to sendemail.php), i tryied everything but i cant fix it. 因此,问题是:当我按下“发送”按钮时,我收到了电子邮件,但它为空(正在从index.php到sendemail.php中获取信息),我尝试了所有操作,但无法修复。

This is the message im getting on my mail: 这是我在邮件中收到的消息:

Nombre: Grado y sección: Correo Electronico: Numero de Telefono: Mensaje: Este es un mensaje automatizado, favor de no contestar al mismo. 编号:密码:电子通讯:数码电话:门萨吉:自动门,不喜欢任何杂项。

(Obviusly its empty) (显然是空的)

I couldn't find the exact issue with your code but I found success by combining the two files into one as seen in the following code. 我找不到您的代码的确切问题,但是通过将两个文件合并为一个文件,如以下代码所示,我找到了成功。

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

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

      $to = "soporte@colegiolavictoria.holixgaming.com";

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

      $headers = "From: " . $email . "\r\n";
      $headers .= "Reply-To: ". $email . "\r\n";
      $headers .= "CC: soporte@colegiolavictoria.holixgaming.com\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>  

I'm guessing that it has something to do with how you are declaring the headers. 我猜这与您声明标头的方式有关。 Try running this, as it's a bit cleaner, and works on my dev machine: 尝试运行它,因为它更干净,并且可以在我的开发机上运行:

<?php

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

$to = "soporte@colegiolavictoria.holixgaming.com";
$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));

?>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM