代码控制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();
}
?>
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'
';Userid: | ';|
password: | ';|
'; echo' |