0

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

我得到了除 first_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;  
?>

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

4

1 回答 1

3

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

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

所以要么使用:

$name = $_POST['name'];

或者在您的表单中创建两个字段,first_name如下last_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 />
于 2013-08-27T10:53:27.450 回答