Home  >  Article  >  Backend Development  >  求大神给指点下这些代码有什么有关问题啊为什么session变量不生效

求大神给指点下这些代码有什么有关问题啊为什么session变量不生效

WBOY
WBOYOriginal
2016-06-13 11:54:00829browse

求大神给指点下这些代码有什么问题啊,为什么session变量不生效啊

<?php  require_once('Connections/yiwuyiwu.php'); ?><br><?php <br />if (!function_exists("GetSQLValueString")) {<br>function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") <br>{<br>  $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;<br><br>  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);<br><br>  switch ($theType) {<br>    case "text":<br>      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";<br>      break;    <br>    case "long":<br>    case "int":<br>      $theValue = ($theValue != "") ? intval($theValue) : "NULL";<br>      break;<br>    case "double":<br>      $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";<br>      break;<br>    case "date":<br>      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";<br>      break;<br>    case "defined":<br>      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;<br>      break;<br>  }<br>  return $theValue;<br>}<br>}<br><br>mysql_select_db($database_yiwuyiwu, $yiwuyiwu);<br>$query_Recordset1 = "SELECT * FROM `user`";<br>$Recordset1 = mysql_query($query_Recordset1, $yiwuyiwu) or die(mysql_error());<br>$row_Recordset1 = mysql_fetch_assoc($Recordset1);<br>$totalRows_Recordset1 = mysql_num_rows($Recordset1);<br>?><br><?php <br />// *** Validate request to login to this site.<br>if (!isset($_SESSION)) {<br>  session_start();<br>}<br>// ***session变量开始了<br>$loginFormAction = $_SERVER['PHP_SELF'];<br>if (isset($_GET['accesscheck'])) {<br>  $_SESSION['PrevUrl'] = $_GET['accesscheck'];<br>}<br><br>if (isset($_POST['Username'])) {<br>  $loginUsername=$_POST['Username'];<br>  $password=(md5($_POST['Password']));<br>  $MM_fldUserAuthorization = "enable";<br>  $MM_redirectLoginSuccess = "index.php";<br>  $MM_redirectLoginFailed = "zhuce.php";<br>  $MM_redirecttoReferrer = false;<br>  //*** 输入账号和密码,判断转向页面。<br>  mysql_select_db($database_yiwuyiwu, $yiwuyiwu);<br>  	<br>  $LoginRS__query=sprintf("SELECT u_id u_name, pass, enable FROM `user` WHERE u_name=%s AND pass=%s",<br>  //*** 启用符号是这个“·”<br>  GetSQLValueString($loginUsername, "text"), GetSQLValueString($password, "text")); <br>   <br>  $LoginRS = mysql_query($LoginRS__query, $yiwuyiwu) or die(mysql_error());<br>  $row_LoginRS = mysql_fetch_assoc($LoginRS);<br>  $loginFoundUser = mysql_num_rows($LoginRS);<br>  <br>  <br>  if ($loginFoundUser) {<br>    <br>    $loginStrGroup  = mysql_result($LoginRS,0,'enable');<br>    <br>    //***   声明三个会话变量并分配值<br>    $_SESSION['MM_Username'] = $loginUsername;<br>    $_SESSION['MM_UserGroup'] = $loginStrGroup;	<br>	$_SESSION['u_id']= $row_LoginRS('u_id');     <br><br>    if (isset($_SESSION['PrevUrl']) && false) {<br>      $MM_redirectLoginSuccess = $_SESSION['PrevUrl'];	<br>    }<br>    header("Location: " . $MM_redirectLoginSuccess );<br>  }<br>  else {<br>    header("Location: ". $MM_redirectLoginFailed );<br>  }<br>}<br>?><br>nbsp;html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><br><br><br><meta><br><title></title><br><br><br><br>  <h3>登录系统</h3><br>  <hr><br><br>
" id="form1" name="form1" method="POST">
  
    
      
用户登陆
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn