-3

我收到此错误:警告:无法修改标头信息 - 标头已由 /Applications/XAMPP/xamppfiles/htdocs/recover.php 中的 /Applications/XAMPP/xamppfiles/htdocs/recover.php:11 发送的标头在线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();
    }
}

?>

关于如何解决这个问题的任何想法?提前致谢

4

1 回答 1

1

You cannot changer header information, redirection in your case, after anything has been output by PHP.

Removing <h1> Recover </h1> will fix the error, but you should rethink your code so that header('Location: recover.php?success'); appears before any HTML output.

于 2013-07-15T00:06:18.293 回答