[英]Getting no info from Contact Form
這是我的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 = "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);
?>
因此,問題是:當我按下“發送”按鈕時,我收到了電子郵件,但它為空(正在從index.php到sendemail.php中獲取信息),我嘗試了所有操作,但無法修復。
這是我在郵件中收到的消息:
編號:密碼:電子通訊:數碼電話:門薩吉:自動門,不喜歡任何雜項。
(顯然是空的)
我找不到您的代碼的確切問題,但是通過將兩個文件合並為一個文件,如以下代碼所示,我找到了成功。
<?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>
我猜這與您聲明標頭的方式有關。 嘗試運行它,因為它更干凈,並且可以在我的開發機上運行:
<?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.