は私がパスワードを投稿し、簡単なログインスクリプトを持って仕事してデータベースPHP:セッションベースのログインスクリプトは
session_start();
include 'core/config.php';
include 'core/db.php';
$checkPWD = $DB_CON -> query('SELECT * FROM users');
$checkPWD->execute();
$pwd = $checkPWD->fetchAll();
if($_POST['password']) {
$md5pwd = md5($_POST['password']);
if($md5pwd == $pwd[2]) {
$_SESSION['login'] = 'true';
$_GET['page'] = 'dashboard';
} else {
$_GET['error'] = 'true';
}
}
この出口でcorrispondenceをチェックして、$ _GET [「エラーは」]に設定され持っていないだろう本当。 パスワードはデータベースのmd5に保存されます。
どうもありがとう
エラーは何ですか? – Mohini
パスワードが正しい場合でも、スクリプトはelseを終了して$ _GET ['error'] = 'true'を取得します – andreaem
このスクリプトは大変です。あなたはusersテーブル全体を選択していますか?そして、あなたはMD5のパスワードを入力します(これは[NOT SECURE](http://security.stackexchange.com/questions/52461/how-weak-is-md5-as-a-password-hashing-function)です)。あなたのデータのループもありません。 [password_hashへの切り替えを検討する](http://stackoverflow.com/questions/14992367/using-php-5-5s-password-hash-and-verify-function-am-i-doing-it-right) – Machavity