do_login.inc.php 代码发错了 重发一下吧:
<body>
<?php
SESSION_start();
include("functions.inc.php");
$form = check_form($_POST["edit"]);
$username = $form["name"];
$password = $form["pass"];
if(!$password == "123456") {
echo("failed!");
exit;
}
$_SESSION["userid"] = "1";
$_SESSION["username"] = $username; //设置session变量为用户名
header("newsedit.php"); //跳转到管理员编辑页面
?>
</body>
输入:admin 123456 执行的时候报错呢Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by on line 11 即 这一行: SESSION_start();Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent on line 11 即 这一行: SESSION_start();Warning: Cannot modify header information - headers already sent by on line 22即这一行:header("newsedit.php");
<body>
<?php
SESSION_start();
include("functions.inc.php");
$form = check_form($_POST["edit"]);
$username = $form["name"];
$password = $form["pass"];
if(!$password == "123456") {
echo("failed!");
exit;
}
$_SESSION["userid"] = "1";
$_SESSION["username"] = $username; //设置session变量为用户名
header("newsedit.php"); //跳转到管理员编辑页面
?>
</body>
输入:admin 123456 执行的时候报错呢Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by on line 11 即 这一行: SESSION_start();Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent on line 11 即 这一行: SESSION_start();Warning: Cannot modify header information - headers already sent by on line 22即这一行:header("newsedit.php");
第二,问题:header前不能有输出,你有
<body>
<?php
已输出body
header();
等要求在所在行前面不能有任何输出.
所以这些最好放在globl.php里,且必须保证第一个包含.
你的
echo("failed!");
就是向浏览器输出东西了,
把这句去掉应该就可以了
session_start();
.
.
.
.
.
.
?>
2 SESSION_start();
3 ?>为了让问题清晰,我把do_login.inc.php的内容简略为只有3行代码了。 运行报错。
Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at C:\wamp\www\00\do_login.inc.php:2) in C:\wamp\www\00\do_login.inc.php on line 2Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at C:\wamp\www\00\do_login.inc.php:2) in C:\wamp\www\00\do_login.inc.php on line 2而我新建了一个session_check.php文件 代码同样只有上面3行,运行 OK!没有报错 。咋回事啊 ??
不过 ,这是为什么呢???
文件名最好不要用.要表达什么意思的文件名用_或者-表示。不然容易出错。
而且在header()前面不能有语句输出。
任何session调用前面都要session_start。
如果单独写的一个:
<?php
session_start();
?>这样的代码都有这样的错误,基本确定是文件BOM的问题了,解决方法有很多,用EditPlus打开保存时不要BOM,或者在网上批量修改。