我继承了这个表格并且我不是编码员所以不确定他们为什么形成不发送消息...只是电子邮件和表格中的名称。
这是代码
<?php
echo 111;
$name = $_POST['name'];
$email = $_POST['email'];
$message = $_POST['message'];
//Sending Email to form owner
$header = "From: $email\n"
. "Reply-To: $email\n";
$subject = "Skills Generation Contact Form";
$email_to = "mail@skillsgen.com";
$message = "name: $name"
. "email: $email\n"
. "message: $message";
if (mail($email_to, $subject ,$message ,$header ))
{
// Message was successfully sent
// To redirect form on a particular page
header("Location:http://www.skillsgeneration.com.au");
}
echo 123;
?>
答案 0 :(得分:0)
如果这是它的全部代码,因为您用$message
覆盖$message = "name: $name". "email: $email\n";
变量。
我不确定您是否正在尝试使用标头方法周围的空括号来实现。
<?php
$name = $_POST['name'];
$email = $_POST['email'];
$message = $_POST['message'];
//Sending Email to form owner
$header = "From: $email\n"
. "Reply-To: $email\n";
$subject = "Website Form";
$email_to = "mail@email.com";
$message = "name: $name"
. "email: $email\n";
. "message: $message";
if(mail($email_to, $subject ,$message ,$header ))
{
// Message was successfully sent
// To redirect form on a particular page
header("Location:http://www.website.com.au");
}
?>
答案 1 :(得分:0)
在你的HTML中,你没有给textarea一个名字
变化:
<textarea value="Message:" onfocus="this.value = '';" onblur="if (this.value == '') {this.value = 'Your Message ';}">Your Message</textarea>
为:
<textarea name="message" value="Message:" onfocus="this.value = '';" onblur="if (this.value == '') {this.value = 'Your Message ';}">Your Message</textarea>
像@Bankzilla一样,你也在覆盖$ message变量。
将其替换为:
$message = "name: $name"."email: $email\n message:$message";