【发布时间】:2013-04-06 19:13:43
【问题描述】:
我想在给我发送电子邮件后重定向用户。
除非我在email()-方法(如header()-方法)之后添加一些内容,否则代码会运行。
有什么提示吗?
function process()
{
$msg = "Form Contents: \n\n";
foreach($this->fields as $key => $field)
$msg .= "$key : $field \n";
$to = 'mymail@gmail.com';
$subject = 'thesubject';
$from = $this->fields['email'];
mail($to, $subject, $msg, "From: $from\r\nReply-To: $from\r\nReturn-Path: $from\r\n");
header('Location: thanks.html');
}
【问题讨论】:
-
你得到什么错误?
-
我曾经遇到过 PHP Parse 错误:语法错误,意外的 'header' (T_STRING),在 D:\xampp\htdocs\process_form.php 中的 D:\xampp\ 中期望函数 (T_FUNCTION) php\logs\php_error_log
-
发送的电子邮件是否没有任何错误?如果您尝试使用 @mail(...) 会怎样?
-
$this->fields 应该是 $field,对吧? $from = $field['email'];
-
是的,电子邮件已发送。但之后的重定向不是。
标签: php http-headers http-redirect