よろしく、
私は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