私はmysqlとphpを初めて使用します。
ユーザー用のテーブルを使用したデータベースの作成に取り組んでいます。
私はデータベースにユーザーを正常に追加することができました。md5を使用したユーザーのパスワード(安全ではないことはわかっています)、オンラインで起動されません。
私の問題は、正しいユーザー名とパスワードに基づいてユーザーをログインさせる方法です。
これが私のコードです
私のロジックは、クエリの実行後、trueまたはfalseのいずれかを返します。
trueの場合、成功したログインを表示し、そうでない場合は失敗します。
ただし、正しいユーザー名とパスワードを入力しても、ログインメッセージが失敗します。
mysqlデータベースを確認しましたが、uesrnameは正しくそこにあります
アイデア?
if(!empty($_POST['userLog']) && !empty($_POST['passLog']))
{
//set the username and password variables from the form
$username = $_POST['userLog'];
$password = $_POST['passLog'];
//create sql string to retrieve the string from the database table "users"
$sql = "SELECT * FROM `users` WHERE userName = '$username' AND password = md5('$password')";
$result = mysql_query($sql);
if ($result == true) {
$return = "<font color=#008000><Center><b>**Successful Login**</b></Center></font>";
} else {
$return = "<font color=#ff0000><Center><b>**Failed Login**</b></Center></font>";
}
print($return);
}