前辈,帮解决下这个有关问题
程序员文章站
2024-01-20 12:57:52
...
前辈,帮解决下这个问题
我做了一个登录用户的页面,做好之后,在纯页面的情况下,我给它了一个登录用户验证。然后在上面生成了这些代码
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
}
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
?>
// *** Validate request to login to this site.
if (!isset($_SESSION)) {
session_start();
}
$loginFormAction = $_SERVER['PHP_SELF'];
if (isset($_GET['accesscheck'])) {
$_SESSION['PrevUrl'] = $_GET['accesscheck'];
}
if (isset($_POST['username'])) {
$loginUsername=$_POST['username'];
$password=$_POST['userpsw'];
$MM_fldUserAuthorization = "";
$MM_redirectLoginSuccess = "admin.php";
$MM_redirectLoginFailed = "index.php";
$MM_redirecttoReferrer = true;
mysql_select_db($database_boardConn, $boardConn);
$LoginRS__query=sprintf("SELECT username, userpsw FROM board_admin WHERE username=%s AND userpsw=%s",
GetSQLValueString($loginUsername, "text"), GetSQLValueString($password, "text"));
$LoginRS = mysql_query($LoginRS__query, $boardConn) or die(mysql_error());
$loginFoundUser = mysql_num_rows($LoginRS);
if ($loginFoundUser) {
$loginStrGroup = "";
if (PHP_VERSION >= 5.1) {session_regenerate_id(true);} else {session_regenerate_id();}
//declare two session variables and assign them
$_SESSION['MM_Username'] = $loginUsername;
$_SESSION['MM_UserGroup'] = $loginStrGroup;
if (isset($_SESSION['PrevUrl']) && true) {
$MM_redirectLoginSuccess = $_SESSION['PrevUrl'];
}
header("Location: " . $MM_redirectLoginSuccess );
}
else {
header("Location: ". $MM_redirectLoginFailed );
}
}
?>
但是我一浏览
页面就出现这样的错误:
Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at E:\AppServ\www\webBoard2\login.php:2) in E:\AppServ\www\webBoard2\login.php on line 5
以前也预见这样问题,那会把// *** Validate request to login to this site.
if (!isset($_SESSION)) {
session_start();
}
这一段的PHP代码放到上面就行了,这次不知道怎么还是不行,帮忙 解决下,谢谢
------解决方案--------------------
我做了一个登录用户的页面,做好之后,在纯页面的情况下,我给它了一个登录用户验证。然后在上面生成了这些代码
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
}
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
?>
// *** Validate request to login to this site.
if (!isset($_SESSION)) {
session_start();
}
$loginFormAction = $_SERVER['PHP_SELF'];
if (isset($_GET['accesscheck'])) {
$_SESSION['PrevUrl'] = $_GET['accesscheck'];
}
if (isset($_POST['username'])) {
$loginUsername=$_POST['username'];
$password=$_POST['userpsw'];
$MM_fldUserAuthorization = "";
$MM_redirectLoginSuccess = "admin.php";
$MM_redirectLoginFailed = "index.php";
$MM_redirecttoReferrer = true;
mysql_select_db($database_boardConn, $boardConn);
$LoginRS__query=sprintf("SELECT username, userpsw FROM board_admin WHERE username=%s AND userpsw=%s",
GetSQLValueString($loginUsername, "text"), GetSQLValueString($password, "text"));
$LoginRS = mysql_query($LoginRS__query, $boardConn) or die(mysql_error());
$loginFoundUser = mysql_num_rows($LoginRS);
if ($loginFoundUser) {
$loginStrGroup = "";
if (PHP_VERSION >= 5.1) {session_regenerate_id(true);} else {session_regenerate_id();}
//declare two session variables and assign them
$_SESSION['MM_Username'] = $loginUsername;
$_SESSION['MM_UserGroup'] = $loginStrGroup;
if (isset($_SESSION['PrevUrl']) && true) {
$MM_redirectLoginSuccess = $_SESSION['PrevUrl'];
}
header("Location: " . $MM_redirectLoginSuccess );
}
else {
header("Location: ". $MM_redirectLoginFailed );
}
}
?>
但是我一浏览
页面就出现这样的错误:
Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at E:\AppServ\www\webBoard2\login.php:2) in E:\AppServ\www\webBoard2\login.php on line 5
以前也预见这样问题,那会把// *** Validate request to login to this site.
if (!isset($_SESSION)) {
session_start();
}
这一段的PHP代码放到上面就行了,这次不知道怎么还是不行,帮忙 解决下,谢谢
------解决方案--------------------
相关文章
相关视频
上一篇: 强大的数据库查询工具Database.NET 9.4.5018.42
下一篇: php搜索功能
推荐阅读
-
前辈,帮解决下这个有关问题
-
php有关问题,你肯定会,帮小弟我这个新手解决一下吧
-
PHP分页赋值有关问题.大大帮助解决一下.了给分附代码
-
各位大牛帮小弟我弄下php加mysqli的扩展有关问题
-
,能否帮忙下小弟解决这个有关问题吗,php foreach循环取到里面所有的值在静态页面显示
-
php的大哥大姐们,帮小弟我解决一个有关问题一下
-
一个关于dedecms系统的有关问题,刚开始学这个系统,遇到个小疑点,望大家帮忙解决。
-
高手帮看上,换了空间就出现以上有关问题,不知道怎么解决
-
有关在Windows下配置PHP Apache Optimizer失败的问题解决方案_PHP
-
PHP分页赋值有关问题.大大帮助解决一下.了给分附代码