コマンドラインから認証しようとしていますが、うまく動作しません。私のコードをチェックして、どこが間違っていたか教えてください。
<?php
echo "enter your username\n";
$username = fgets(STDIN);
echo "your password\n";
$password = fgets(STDIN);
echo "enter your new password\n";
$newpassword = fgets (STDIN);
//connecting to database
$db = mysql_connect("localhost","sqldata","sqldata") or die(mysql_error());
//selecting our database
$db_select = mysql_select_db("accounts", $db) or die(mysql_error());
$sql = mysql_query ("select * from uptable where username ='$username'");
$result = mysql_fetch_assoc($sql);
$oldpassword = $result['password'];
if ($password != $oldpassword)
{
echo "error";
}
else
{
mysql_query("update uptable set password = '$newpassword' where username ='$username'");
echo "Your Password has been successfully changed";
}
?>