2013-02-12 93 views
0

我创建了一个邮件表单。 PHP页面读取输入,将其发送到邮件,然后重定向到某个页面。挺直的,之前做过。邮件得到发送,但您不会被重定向。php标头重定向不起作用

HTML表单:

<form action="mailversturen.php" method="post"> 
<input type="text" name="naam" placeholder="Naam" class="inputtype" /><br /> 
<input type="text" name="email" placeholder="Email" class="inputtype" /><br /> 
<textarea name="bericht" placeholder="Bericht"></textarea> 
<input type="reset" value="Reset" class="buttontype" /> 
<input type="submit" value="Verstuur" class="buttontype" /> 
</form> 

PHP代码:

<?php 
$name = $_POST['naam']; 
$email = $_POST['email']; 
$message = $_POST['bericht']; 

$to = "[email protected]"; 
$subject = "Bericht van $name"; 
$headers = "From: $email \r\n"; 

mail($to,$subject,$message,$headers); 

header('Location: http://www.newlocation.nl/'); 
?> 

我在做什么错?

+0

为我工作.. – 2013-02-12 21:03:51

+1

type exit;在header()之后; – 2013-02-12 21:04:02

+2

你可能在'<?php'之前或'?>'之后有一些空白或者正在发出某种类型的通知 – 2013-02-12 21:04:07

回答

0

尝试在您打开<?php标记后添加@ob_start();

这将打开输出缓冲。我将它与所有header(...)重定向结合使用。

+0

如果存在过早输出,那么添加ob_start已经太晚了。 – mario 2013-02-12 21:09:13