在回调请求表单中遇到一些问题我正在尝试为移动网站构建。基本上问题是我收到了电子邮件,但字段是空的,好像它已被发送而没有输入任何输入字段。显然,PHP抓住我的字段并发布它们肯定存在问题,但我似乎无法弄清楚我做错了什么:
<?php
$EmailFrom = $_POST['ftEmail'];
// $EmailTo = "me@xxxx.com";
$EmailTo = "me@xxxxx.com";
$Subject = "Call back request from a mobile";
$Name = Trim(stripslashes($_POST['ftName']));
$Email = Trim(stripslashes($_POST['ftEmail']));
$Tel = Trim(stripslashes($_POST['ftTel']));
/* - IF NEED TO CONNECT TO DATABASE
$con = mysql_connect("xxx","xxx","xxx");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("farmpro1_mosuro", $con);
$sql="INSERT INTO contact_form (Name, Tel, Email)
VALUES
('$_POST[Name]','$_POST[Tel]','$_POST[Email]')";
if (!mysql_query($sql,$con))
{
die('Error: ' . mysql_error());
}
*/
// email body text
$Body = "";
$Body .= "Name: ";
$Body .= $Name;
$Body .= "\n";
$Body .= "Email: ";
$Body .= $Email;
$Body .= "\n";
$Body .= "Tel: ";
$Body .= $Tel;
$Body .= "\n";
// send the email
$success = mail($EmailTo, $Subject, $Body, "From: <$EmailFrom>");
// redirect to thank you page
if ($success){
print "<meta http-equiv=\"refresh\" content=\"0;URL=contact_thanks.php\">";
}
else{
print "<meta http-equiv=\"refresh\" content=\"0;URL=error.html\">";
}
mysql_close($con)
?>
<form action="send_request_mobile.php">
<input type="text" value="ftName" name="ftName" id="ftName"><br>
<input type="text" value="ftEmail" name="ftEmail" id="ftEmail"><br>
<input type="text" value="ftTel" name="ftTel" id="ftTel">
<input type="submit" value="SEND" class="ftSubmit">
</form>
任何帮助都会很棒!
谢谢,
答案 0 :(得分:4)
您的表单没有method
属性,因此默认为GET
,您正在寻找$_POST
中的数据。
<form action="send_request_mobile.php" method="post">