福
福特饱
Unregistered / Unconfirmed
GUEST, unregistred user!
本人初学PHP+MYSQL,写了一段小的用户验证程序,可是出现了问题:
本来数据库用SELECT查找用户可以用,但是我把密码用PASSWORD()加密后,
再用SELECT * FROM USER WHERE PASSWORD=PASSWORD('$PASS');查找就找不到了
,这是怎么回事?我的源代码如下:
<?
$select=mysql_select_db('bbs') ;
mysql_connect() or die ("Problem connecting to DataBase");
$query="select * from user where UserName='$username' and Password='$pass'";
$result = mysql_query($query);
if ($r = mysql_fetch_array($result)) {
$user = $r["UserName"];
$permit = $r["Permit"];
echo "User Login, press <a href=/"login.php?user=$user&permit=$permit/">here</a> to continue.";
}
else
{
echo "Can not login.
Please check your username and password.";
}
?>
本来数据库用SELECT查找用户可以用,但是我把密码用PASSWORD()加密后,
再用SELECT * FROM USER WHERE PASSWORD=PASSWORD('$PASS');查找就找不到了
,这是怎么回事?我的源代码如下:
<?
$select=mysql_select_db('bbs') ;
mysql_connect() or die ("Problem connecting to DataBase");
$query="select * from user where UserName='$username' and Password='$pass'";
$result = mysql_query($query);
if ($r = mysql_fetch_array($result)) {
$user = $r["UserName"];
$permit = $r["Permit"];
echo "User Login, press <a href=/"login.php?user=$user&permit=$permit/">here</a> to continue.";
}
else
{
echo "Can not login.
Please check your username and password.";
}
?>