2013-07-15 65 views
-3

我得到这个错误:警告:不能更改头信息 - 头已经发出的(输出开始/Applications/XAMPP/xamppfiles/htdocs/recover.php:11)/应用程序/ XAMPP/xamppfiles/htdocs中/ recover.php上线22警告:不能更改头信息

这是我的代码,以便您可以看看:

<?php 

include 'core/init.php'; 
logged_in_redirect(); 

?> 


<h1> Recover </h1> 

<?php 
if (isset($_GET['success']) === true && empty($_GET['success']) === true) { 
?> 
    <p>thanks we have emailed you</p> 
<?php 
} else { 
    $mode_allowed = array('username', 'password'); 
     if(isset($_GET['mode']) === true && in_array($_GET['mode'], $mode_allowed) === true) { 
      if(isset($_POST['email']) === true && empty($_POST['email']) === false){ 
       if (email_exists($_POST['email']) === true) { 
        recover($_GET['mode'], $_POST['email']); 
        header('Location: recover.php?success'); 
        exit(); 
       } else { 
        echo 'we cant find that email in our database'; 
       } 
      } 

?> 
    <form action="" method="post"> 
     Please enter your email adress:<br> 
     <input type="text" name="email"><br> 
     <input type="submit" value="Recover!"> 


    </form> 

<?php 
    } else { 
     header('Location: index.php'); 
     exit(); 
    } 
} 

?> 

任何想法我如何能解决这个问题? 在此先感谢

+0

要么执行javascript/meta刷新,要么删除'

恢复

'和if语句中的html。 –

+0

解决!多谢你们! –

+0

可能是咬人的php功能的前3名...... – fvu

回答

1

你不能在PHP输出任何东西后改变头信息,重定向你的情况。

删除<h1> Recover </h1>将修复该错误,但您应该重新考虑您的代码,以便header('Location: recover.php?success');出现在任何HTML输出之前。

+0

非常感谢您的帮助! :) –

相关问题