Heim > Artikel > Backend-Entwicklung > mysql_num_rows()函数,该如何处理
mysql_num_rows()函数
以下是代码部分:
$username=$_POST["name"];
$password=$_POST["password"];
if($username&&$password)
{
if(strpos($username," ")!==false)echo "用户名非法";
else
{
$con=mysql_connect("localhost","root","1");
mysql_select_db("manage",$con);
$sql="
select password
from user
where username='$username'
";
$query=mysql_query($sql);
$row=mysql_num_rows($query);
if($row!=0)echo'登录成功';
else
echo '登录失败';
}
}
?>