doulongdan2264 2013-07-15 00:00
浏览 28

警告:无法修改标题信息[重复]

This question already has an answer here:

I get this error: Warning: Cannot modify header information - headers already sent by (output started at /Applications/XAMPP/xamppfiles/htdocs/recover.php:11) in /Applications/XAMPP/xamppfiles/htdocs/recover.php on line 22

This is my code so that you can take a look:

<?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();
    }
}

?>

ANY IDEA ON HOW CAN I FIX THIS? Thanks in advance

</div>
  • 写回答

1条回答 默认 最新

  • douzhuo2722 2013-07-15 00:06
    关注

    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.

    评论

报告相同问题?

悬赏问题

  • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
  • ¥20 怎么用dlib库的算法识别小麦病虫害
  • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
  • ¥15 java写代码遇到问题,求帮助
  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?