PHP中的session问题

来源:百度知道 编辑:UC知道 时间:2024/05/21 19:37:20
<?php
session_start();

if (isset($_POST['userid'])&&isset($_POST['password']))
{
// if the user has just tried to log in
$userid=$_POST['userid'];
$password=$_POST['password'];

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

if(mysqli_connect_errno())
{
echo 'Connetion to database failed(1):'.mysqli_connect_errno();
exit();
}

$query='select * from authorized_users '."where name='$userid' "." and password=shal('$password')";

$result=$db_conn->query($query);

if($result->num_rows>0)
{
//if they are in the database register the user id
$_SESSION['valid_user']=$userid;
}
$db_conn->close();
}
?>

$query='select * from authorized_users '."where name='$userid' "." and password=shal('$password')";这里改成

$ps = sha1($password);
$query='select * from authorized_users '."where name='$userid' "." and password= $ps";
你试试可不可以,顺便你得把系统的提示错误给帖出来,这样方便观看。