This registers a global variable. If you want to register a session variable inside a function, you need to make sure to make it global using global() or use the session arrays as noted below. 如何使用global()|??
session_start(); if ($select==0) { $dbh = mysql_connect("localhost:3306","root","pass13579"); mysql_select_db("thebest");//选择数据库 //验证 $query="select * from xuesheng where STUDENTID= '$name' and STUDENTID= '$password' "; $res = mysql_query($query, $dbh); if($row=mysql_fetch_row($res)) {
如何使用global()|??
if ($select==0)
{
$dbh = mysql_connect("localhost:3306","root","pass13579");
mysql_select_db("thebest");//选择数据库
//验证
$query="select * from xuesheng where STUDENTID= '$name' and STUDENTID= '$password' ";
$res = mysql_query($query, $dbh); if($row=mysql_fetch_row($res))
{
session_register("reg_stu_user");//注册用户学生
$reg_stu_user = $name;
Header("Location: choose_option.php");
exit();
}
}
是否要把reg_stu_user设成global