下面的源代码可以成功的运行:
<?php
session_start();
include("config.php");
$db = db_connect();$name1 = $_POST["admin_name"];
$admin_passwd = $_POST["admin_pwd"];
$admin_passwd = md5($admin_passwd);
$pageRandCode = $_POST['admin_check'];
session_register("username");
$username = $name1;
?>
<?php?>
<?php
if (!isset($_SESSION['username']))
{
echo "<p align=center>";
echo "<font color=#FF0000 size=5><strong><big>";
echo "对不起,请您先登录!";
echo "</big></strong></font></p>";
exit();
}
$sql = "select * from admin where user = '$name1'";
$result = mysql_query($sql);
if ($answer = mysql_fetch_array($result))
{
if ($admin_passwd == $answer["passwd"] && $_SESSION["verifyCode"] == $pageRandCode)
{
db_close();
header("Location: 1.php?id=$name1");
} elseif ($admin_passwd != $answer["passwd"])
{
db_close();
header("Location: 2.php");
} elseif ($_SESSION["verifyCode"] != $pageRandCode)
{
db_close();
header("Location: 3.php");
}
}
db_close();
echo '该用户不是管理员,无权登录!';
?>
但是我把中间那个<?php ?>标记符去掉后,却显示如下的错误:
Warning: Cannot modify header information - headers already sent by (output started at E:\AppServ\www\test4\admin\admin_check.php:13) in E:\AppServ\www\test4\admin\admin_check.php on line 32Warning: mysql_close(): 3 is not a valid MySQL-Link resource in E:\AppServ\www\test4\admin\config.php on line 28
该用户不是管理员,无权登录!
我就奇怪那对标记符里面什么代码都没有啊,怎么会有大的影响啊???
<?php
session_start();
include("config.php");
$db = db_connect();$name1 = $_POST["admin_name"];
$admin_passwd = $_POST["admin_pwd"];
$admin_passwd = md5($admin_passwd);
$pageRandCode = $_POST['admin_check'];
session_register("username");
$username = $name1;
?>
<?php?>
<?php
if (!isset($_SESSION['username']))
{
echo "<p align=center>";
echo "<font color=#FF0000 size=5><strong><big>";
echo "对不起,请您先登录!";
echo "</big></strong></font></p>";
exit();
}
$sql = "select * from admin where user = '$name1'";
$result = mysql_query($sql);
if ($answer = mysql_fetch_array($result))
{
if ($admin_passwd == $answer["passwd"] && $_SESSION["verifyCode"] == $pageRandCode)
{
db_close();
header("Location: 1.php?id=$name1");
} elseif ($admin_passwd != $answer["passwd"])
{
db_close();
header("Location: 2.php");
} elseif ($_SESSION["verifyCode"] != $pageRandCode)
{
db_close();
header("Location: 3.php");
}
}
db_close();
echo '该用户不是管理员,无权登录!';
?>
但是我把中间那个<?php ?>标记符去掉后,却显示如下的错误:
Warning: Cannot modify header information - headers already sent by (output started at E:\AppServ\www\test4\admin\admin_check.php:13) in E:\AppServ\www\test4\admin\admin_check.php on line 32Warning: mysql_close(): 3 is not a valid MySQL-Link resource in E:\AppServ\www\test4\admin\config.php on line 28
该用户不是管理员,无权登录!
我就奇怪那对标记符里面什么代码都没有啊,怎么会有大的影响啊???
?>
<?php?>
<?php
if (!isset($_SESSION['username']))
{----------------------
$username = $name1;
if (!isset($_SESSION['username']))
{
<?php?>
<?php全去掉。
即便是空格也视为输出。
session_start()前不能有输出
<??>外的所有空行删除