【发布时间】:2017-07-27 09:22:24
【问题描述】:
提交按钮在contact-us.html,代码在contact-us.php。
我尝试使用header('Location: example');,但没有成功...(我也尝试使用页面的 URL:header('Location: http://www.example.com/contact-us.html');)
有什么想法吗?
<?php
if($_POST["submit"]) {
$recipient="example@gmail.com";
$subject="Form to email message";
$sender=$_POST["firstname"];
$senderlast=$_POST["lastname"];
$senderemail=$_POST["senderemail"];
$message=$_POST["message"];
$mailBody="First Name: $sender\nLast Name: $senderlast\nEmail: $senderemail\n\nMessage: $message";
header('Location: /contact-us.html'); /*Something Wrong?*/
mail($recipient, $subject, $mailBody, "From: $sender <$senderemail>")
}
【问题讨论】:
-
您想将用户发送回contact us.html吗?发送电子邮件后的页面?
-
是的!当按下按钮时,它会转到 php 页面并停留在那里
-
邮件是否发送?可能是
if($_POST['submit'])是false并且标题从未设置。 -
是的,邮件工作正常,我可以接收所有电子邮件。只有重定向位不起作用...
-
我希望你确实意识到邮件头是在邮件功能之前发送的。这意味着如果可行,您的邮件将永远不会被发送