我的联系页面上有这个表格:
<?php
if (isset($_REQUEST['email']))
//if "email" is filled out, send email
{
//send email
$name = $_REQUEST['name'] ;
$email = $_REQUEST['email'] ;
$phone = $_REQUEST['phone'] ;
$message = $_REQUEST['message'] ;
mail("contact@*****.com", $name,
$message, "From:" . $email);
echo "Thank you for using our mail form. <br><br>We will get back to you within 48 hours.";
}
else
//if "email" is not filled out, display the form
{
echo "<br><form method='post' action='enquiry.php' align='center'>
<strong>Name: </strong><input class='textbox' name='name' type='text'><br><br>
<strong>Email: </strong><input class='textbox' name='email' type='text'><br><br>
<strong>Phone: </strong><input class='textbox' name='phone' type='text'><br><br>
<strong>Message: </strong><br>
<textarea class='textbox' name='message' rows='15' cols='40'>
</textarea><br>
<input type='submit'><br><br>
</form>";
}
?>
当有人提交表单时,会向我发送电子邮件。
但是当我尝试将$phone
添加到我的电子邮件代码中时。它没有把邮件发给我。
有人可以告诉我我可以在哪里添加这个吗?谢谢。
答案 0 :(得分:3)
这样做:
$message = $_REQUEST['message'].$phone;
这会在手机号码上附上您的信息。
答案 1 :(得分:1)
那么问题是什么,在发送之前将数字附加到$ message。
$message .= $phone;
答案 2 :(得分:0)
试试吧
<?php
if (isset($_REQUEST['email'])) //if "email" is filled out, send email
{
//send email
$name = $_REQUEST['name'] ;
$email = $_REQUEST['email'] ;
$phone = $_REQUEST['phone'] ;
$message = $_REQUEST['message'] ;
$message_text = $message." Phone no:".$phone; // combine here $message and $phone to $message_text
mail("contact@*****.com", $name, $message_text, "From:" . $email); // now use $message_text here to send mail
echo "Thank you for using our mail form. <br><br>We will get back to you within 48 hours.";
}
else //if "email" is not filled out, display the form
{
echo "<br><form method='post' action='enquiry.php' align='center'>
<strong>Name: </strong><input class='textbox' name='name' type='text'><br><br>
<strong>Email: </strong><input class='textbox' name='email' type='text'><br><br>
<strong>Phone: </strong><input class='textbox' name='phone' type='text'><br><br>
<strong>Message: </strong><br>
<textarea class='textbox' name='message' rows='15' cols='40'>
</textarea><br>
<input type='submit'><br><br>
</form>";
}
?>