The strange question of session (has been searched, oneself also cannot solve) _php tutorial

Source: Internet
Author: User
The strange question of the session (has been searched, oneself also cannot solve)

My landing page, is to determine whether to login, directly enter the address of the landing window, the first time you have no access to the session file appears admin|b:0; Refresh once, appear you have landed
notice:undefined Index:name in d:usrwwwhtmldengluindex.php on line 5
111122223333
The file in the session file becomes admin|b:1; The value of admin is 1. Strange!!!
This is the code for index.php:

$admin =false;
if (isset ($_session[' admin ') &&$_session[' admin ']=true)
{echo "You have landed";
echo $_session[' name '];
}
Else
{$_session[' admin ']=false;

Die ("You are not authorized to access");
Header ("Location:login.htm");
}

?>

111122223333






In the previous verification, if the user name and password are correct, let $_session[' admin ' = true;

This is the login.php code:
$XM =$_post[' xingming '];
$ps =$_post[' password '];
$_session[' admin '] = false;
$link = mysql_connect (' localhost ', ' root ', ');
$db = mysql_select_db (' HEHETSG ');
$result = mysql_query ("SELECT * from user where user = ' $xm ' and PSW = ' $ps '");
if ($row =mysql_fetch_array ($result))
{if ($row [' PSW ']== $ps and $row [' Flag ']==1)
{$_session[' name ']= $row [' name '];
$_session[' admin ' = true;
echo "Welcome administrator to enter!" ";
echo "Management interface";

}
Else
{echo "is not an administrator.) I am sorry! ";
echo "Click Back";
}
}
else {echo "Your information is not complete! ";
echo "Click Back";
}

?>

Enter the login information here:





<title>Landing page</title>










[ ]



echo "
"; Echo"
"; Echo"
";

High!!!!!

Help me solve is high AH!! Oh

Add error_reporting (0) before Session_Start ();

Isset ($_session[' admin ') &&$_session[' admin ']=true
It's a logical mistake.

Posted by July 15 on 2008-7-19 16:33 [url=http://www.111cn.cn/bbs/redirect.php?goto=findpost&pid=505295&ptid=70090] Link marker [Img]http://www.111cn.cn/bbs/images/common/back.gif[/img][/url]
Add error_reporting (0) before Session_Start ();
Thanks, but ...
Add this, there is no mistake, but my verification or not AH

The login has become the administrator login.
The verification is meaningless.

Originally Posted by dongxin1390008 on 2008-7-19 16:34 [url=http://www.111cn.cn/bbs/redirect.php?goto=findpost&pid=505300& ptid=70090] link marker [Img]http://www.111cn.cn/bbs/images/common/back.gif[/img][/url]
Isset ($_session[' admin ') &&$_session[' admin ']=true
It's a logical mistake.
What's the right way to write it?

Die ("You are not authorized to access");
Header ("Location:login.htm");

There's a problem here too.


Cannot have any output in front of header

The logical equals is 2 equals, the assignment is an equal sign,
Isset ($_session[' admin ') &&$_session[' admin ']=true
You write this is as long as my $_session["admin" is not empty can be landed, so the back of the
Correct:
Isset ($_session[' admin ') &&$_session[' admin ']==true

Would you please post the correct code?

Help Novice,
Very grateful.

http://www.bkjia.com/PHPjc/632376.html www.bkjia.com true http://www.bkjia.com/PHPjc/632376.html techarticle session of the strange problem (has been searched, I also can not solve) my landing page, is to determine whether to login, directly enter the address to bypass the landing window, the first occurrence you have no right ...

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.