问候,
我是 PHP 新手。这是我为登录页面编写的一个小型登录脚本。它检查数据库中的用户名和密码。
<?php
$con = mysqli_connect("localhost","root","saw","gehriroute");
if(mysqli_connect_errno())
{
echo "could not connect to the database";
exit;
}
else
{
echo "database runing <br>";
}
$uname = trim($_POST['uname']);
$password = trim($_POST['password']);
echo "username and password are $uname and $password <br>";
$query = "select count(*) from login where username = '".$uname."' and password = '".$password."' ";
$result = mysqli_query($query,$con);
if(!$result)
{
echo "query failed";
}
$row = mysqli_fetch_row($result);
$count = $row[0];
if($count > 0 )
{
echo "yes your are logged in";
}
else
{
echo "wrong username or password";
}
?>
它没有连接到数据库的问题,但也没有响应。我打赌脚本不会通过 mysql_error() 函数。我尝试使用mysql_error()
函数对其进行调试,它没有返回任何内容。我可以用来调试和纠正错误的其他东西是什么?
输出:
database runing username and password are ateev and saw query failed