代码-自学PHP mysql web开发小次鸟,寻求大神帮助 第23章会话控制

WBOY
Release: 2016-06-02 11:32:49
Original
946 people have browsed it

代码控制php会话

代码运行一直提示我第23行有错误
session_start();//开始会话

if (isset($_POST['userid'])&&isset($_POST['password']))
{//使用者尝试登录
$userid=$_POST['userid'];
$password=$_POST['password'];

$db_conn=new mysqli('localhost','root','','auth');

if(mysqli_connect_errno()){
echo 'Connection to database failed:'.mysqli_connect_error();
exit();
}

$query='select * from authorised_users'
."where name='$userid'"
."and password='$password'";

$result=$db_conn->query($query);
if ($result->num_rows >0) {
$_SESSION['valid_user']=$userid;
}

$db_conn->close();
}
?>


home page

if(isset($_SESSION['valid_user']))
{
echo 'you are logged in as'.$_SESSION['valid_user'].'
';
echo 'log out
';

}
else
{
if (isset($userid))
{
echo 'Could not log you in.
';
}
else
{
echo 'you are not logged in';
}

echo'

';
echo'';
echo'';
echo'';
echo'';
echo'';
echo'';
echo'
Userid:
password:
';
echo'
';
}
?>


Members section

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!