PHP session的问题,页面跳转后失效李

两个PHP文件,第一个文件

<?php
session_start();
$uid=$_POST["uid"];
$upw=$_POST["upw"];
$sqlcon=mysql_connect("localhost","root","");
echo $sqlcon;
if(!$sqlcon)
{
die('Could not connect: ' . mysql_error());

}
else
{
mysql_select_db("uplatform",$sqlcon);
$result=mysql_query("select * from logincontroll where uid='$uid' and upw='$upw'",$sqlcon);
if(mysql_num_rows($result)!=0)
{
echo "<meta http-equiv='refresh' content='0;url=logined.html'>";
}
else
{
$_session['sta']="error";
echo $_session['sta'];
echo "<meta http-equiv='refresh' content='0;url=file.html'>";
}

}
mysql_close($sqlcon)
?>
创建完SESSION跳转到FILE.php
file.php内容
<?php session_start();
$ses=$_session['sta'];
echo $ses;
?>
这是个登录控制的功能,安设想,如果帐号密码不正确,保存个session['sta'],跳转到file.php,php会显示出session['sta']的内容,但是实际上跳转后什么都不显示

第1个回答  2012-03-16
第一你查询成功后没看到session赋值, 大写 $_SESSION['sta'],变蓝色字就正常的
,第二你转向的时候能不能不要用这个转向,太土了,用js转向也比这个好啊
echo "<script>location='file.php'</script>";
如果都不是这些问题,可能是你php.ini配置session有错误
第2个回答  2012-03-16
$_session['sta'];
要大写
$_SESSION['sta']本回答被提问者采纳

相关了解……

你可能感兴趣的内容

本站内容来自于网友发表,不代表本站立场,仅表示其个人看法,不对其真实性、正确性、有效性作任何的担保
相关事宜请发邮件给我们
© 非常风气网