php电子邮件功能不会打印电子邮件值

时间:2016-02-03 12:21:36

标签: php

我正在使用以下代码发送电子邮件

<?php
if(isset($_POST['submit']))
{
$name = htmlspecialchars($_REQUEST['name']);

$email = htmlspecialchars($_REQUEST['email']);

$mobile = htmlspecialchars($_REQUEST['mobile']);

$company = htmlspecialchars($_REQUEST['company']);

$qty = htmlspecialchars($_REQUEST['qty']);

//$upload = htmlspecialchars($_REQUEST['upload']);

$msg = htmlspecialchars($_REQUEST['msg']);
}

$to="example@gmail.com";

$subject = "Order Information";

$message.= "FirstName: " . $name . "\n";

$message .= "Email: " . $email . "\n";

$message .= "ContactNo: " . $mobile . "\n";

$message .= "Company: " . $company . "\n";

$message .= "Quantity: " . $qty . "\n";

//$message .= "Upoload: " . $upload . "\n";

$msg = "Message: " . $msg . "\n";


if(mail($to, $subject, $message))
{   echo 'thank you';   }
else{ echo 'error';}

?>

它成功发送电子邮件,但电子邮件中的所有字段为: 名字: 电子邮件: 联系方式: 公司: 量:

请说明代码???

有什么问题

2 个答案:

答案 0 :(得分:0)

提交的值为空..尝试使用此

<input type="submit" name="submit" value="submit" />

OR

<input type="hidden" name="submit" value="submit" />
<button type="submit" name="btn">Submit</button>

答案 1 :(得分:0)

表单方法必须使用Post示例:

<form method='POST' name='test'>your input n button </form>