在PHP表单提交上不发布first_name&姓

时间:2013-08-27 10:47:47

标签: php html contact-form

我按照一个简单的教程在这里工作:http://estrellaprofessional.com/contact.html

除了fist_name和last_name之外,我获取了所有捕获的值。

我使用的代码如下:

<?php
$country=$_POST['country'];
$prospect=$_POST['prospect'];
$first_name = $_POST['first_name'];
$last_name = $_POST['last_name'];
$phone = $_POST['phone'];
$message = $_POST['message'];

$all=
"email: ".$email."\r\n".
"Contact Form Submission ".$subject."\r\n".
"country: ".$country."\r\n".
"prospect: ".$prospect."\r\n".
"first_name: ".$first_name."\r\n".
"last_name: ".$last_name."\r\n".
"message: ".$message."\r\n";

    $mailheaders = "From: $email\r\n"; 
    $mailheaders .= "To: amarkmc@gmail.com\r\n"; 
    $headers .= "MIME-Version: 1.0\n"; 
    $headers .= "Content-type: text/html; charset=iso-8859-1\n"; 
        mail($toaddress, $subject, $all, $mailheaders);  
          echo("Thank you $name for your interest in Estrella Professional.  Someone 

from Estrella Professional will be in contact with you soon.  Feel free to continue to browse the site.");  
        die;  
?>

做一个菜鸟我不知道自己做错了什么?有人指出我正确的方向。 提前谢谢!

1 个答案:

答案 0 :(得分:3)

根据我在链接中看到的HTML代码,您在first_namelast_name的表单中没有字段。您只有以下内容:

<input name="name" type="text" style="width: 98%;" class="input-text" />
<br />

所以要么使用:

$name = $_POST['name'];

或者在您的表单中设置两个名为first_namelast_name的字段,如下所示:

<label>Given Name*</label>
<input name="first_name" type="text" style="width: 98%;" class="input-text" />
<br />
<label>Surname*</label>
<input name="last_name" type="text" style="width: 98%;" class="input-text" />
<br />