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");
解决方案 »
- if语句错误
- ajax怎么就跳转了呢?
- php特别简单程序编辑求帮助~谢谢大师大神十分感谢啦~
- 求从一个html代码中提取出图片的地址的方法
- php怎么做到这个简单功能啊?
- 我怎么练不上mysql啊
- 请高手指教similar_text这个函数怎么用,请举个具体的例子!
- 一个php认证登陆的问题
- 在window98下使用 apache ,老是有一个黑乎乎的窗口,能不能不让它出来?
- MySQL查询问题
- 我登录一个网站的时候,建立了session后,我之后跳转到了一个html页面,请问在浏览这个页面的时候发出的header中也有sessionid么
- php preg_replace函数正则替换问题!望高手授业解惑~~小妹感激不尽
第二,问题: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,或者在网上批量修改。