求大神给指点下这些代码有什么问题啊,为什么session变量不生效啊
<?php require_once('Connections/yiwuyiwu.php'); ?><?phpif (!function_exists("GetSQLValueString")) {function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { $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;}}mysql_select_db($database_yiwuyiwu, $yiwuyiwu);$query_Recordset1 = "SELECT * FROM `user`";$Recordset1 = mysql_query($query_Recordset1, $yiwuyiwu) or die(mysql_error());$row_Recordset1 = mysql_fetch_assoc($Recordset1);$totalRows_Recordset1 = mysql_num_rows($Recordset1);?><?php// *** Validate request to login to this site.if (!isset($_SESSION)) { session_start();}// ***session变量开始了$loginFormAction = $_SERVER['PHP_SELF'];if (isset($_GET['accesscheck'])) { $_SESSION['PrevUrl'] = $_GET['accesscheck'];}if (isset($_POST['Username'])) { $loginUsername=$_POST['Username']; $password=(md5($_POST['Password'])); $MM_fldUserAuthorization = "enable"; $MM_redirectLoginSuccess = "index.php"; $MM_redirectLoginFailed = "zhuce.php"; $MM_redirecttoReferrer = false; //*** 输入账号和密码,判断转向页面。 mysql_select_db($database_yiwuyiwu, $yiwuyiwu); $LoginRS__query=sprintf("SELECT u_id u_name, pass, enable FROM `user` WHERE u_name=%s AND pass=%s", //*** 启用符号是这个“·” GetSQLValueString($loginUsername, "text"), GetSQLValueString($password, "text")); $LoginRS = mysql_query($LoginRS__query, $yiwuyiwu) or die(mysql_error()); $row_LoginRS = mysql_fetch_assoc($LoginRS); $loginFoundUser = mysql_num_rows($LoginRS); if ($loginFoundUser) { $loginStrGroup = mysql_result($LoginRS,0,'enable'); //*** 声明三个会话变量并分配值 $_SESSION['MM_Username'] = $loginUsername; $_SESSION['MM_UserGroup'] = $loginStrGroup; $_SESSION['u_id']= $row_LoginRS('u_id'); if (isset($_SESSION['PrevUrl']) && false) { $MM_redirectLoginSuccess = $_SESSION['PrevUrl']; } header("Location: " . $MM_redirectLoginSuccess ); } else { header("Location: ". $MM_redirectLoginFailed ); }}?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title></title></head><body> <h3 id="登录系统">登录系统</h3> <hr /><form ACTION="<?php echo $loginFormAction; ?>" id="form1" name="form1" method="POST"> <table width="250" border="1" align="center" cellpadding="0" cellspacing="0"> <tr> <td colspan="2" nowrap="nowrap" bgcolor="#3366CC"><div align="center"><font color="#FFFFFF">用户登陆</font></div></td> </tr> <tr> <td width="100" nowrap="nowrap"><div align="right"><font color="#000000">用户名:</font></div></td> <td width="235"> <div align="left"> <input name="Username" type="text" id="Username" /> </div></td> </tr> <tr> <td width="100" nowrap="nowrap"><div align="right"><font color="#000000">密码:</font></div></td> <td width="235"> <div align="left"> <input name="Password" type="password" id="Password" value="" /> </div></td> </tr> <tr> <td colspan="2"><div align="right"> <a href="/test/zhuce.php">注册</a> <input type="submit" name="Submit" value="登陆" /> </div></td> </tr> </table></form></body></html><?phpmysql_free_result($Recordset1);?>
回复讨论(解决方案)
你怎么知道没有生效的?
你怎么知道没有生效的?
因为登录以后我计划用session变量做了if语句,结果if语句没生效
你用了哪个session,你可以echo一下看是否有值。
你把相关代码贴出来

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

Long URLs, often cluttered with keywords and tracking parameters, can deter visitors. A URL shortening script offers a solution, creating concise links ideal for social media and other platforms. These scripts are valuable for individual websites a

Following its high-profile acquisition by Facebook in 2012, Instagram adopted two sets of APIs for third-party use. These are the Instagram Graph API and the Instagram Basic Display API.As a developer building an app that requires information from a

Laravel simplifies handling temporary session data using its intuitive flash methods. This is perfect for displaying brief messages, alerts, or notifications within your application. Data persists only for the subsequent request by default: $request-

This is the second and final part of the series on building a React application with a Laravel back-end. In the first part of the series, we created a RESTful API using Laravel for a basic product-listing application. In this tutorial, we will be dev

Laravel provides concise HTTP response simulation syntax, simplifying HTTP interaction testing. This approach significantly reduces code redundancy while making your test simulation more intuitive. The basic implementation provides a variety of response type shortcuts: use Illuminate\Support\Facades\Http; Http::fake([ 'google.com' => 'Hello World', 'github.com' => ['foo' => 'bar'], 'forge.laravel.com' =>

The PHP Client URL (cURL) extension is a powerful tool for developers, enabling seamless interaction with remote servers and REST APIs. By leveraging libcurl, a well-respected multi-protocol file transfer library, PHP cURL facilitates efficient execution of various network protocols, including HTTP, HTTPS, and FTP. This extension offers granular control over HTTP requests, supports multiple concurrent operations, and provides built-in security features.

Do you want to provide real-time, instant solutions to your customers' most pressing problems? Live chat lets you have real-time conversations with customers and resolve their problems instantly. It allows you to provide faster service to your custom

The 2025 PHP Landscape Survey investigates current PHP development trends. It explores framework usage, deployment methods, and challenges, aiming to provide insights for developers and businesses. The survey anticipates growth in modern PHP versio
