Difference between revisions of "Checking the password using hashes and salt"
From MyWiki
(Created page with "<source lng="php"> $check = hash('md5', $salt.$_POST['pass']); $stmt = $pdo->prepare('SELECT user_id, name FROM users WHERE email = :em AND password = :pw'); $stmt->execu...") |
|||
Line 1: | Line 1: | ||
− | <source | + | <source lang="php"> |
$check = hash('md5', $salt.$_POST['pass']); | $check = hash('md5', $salt.$_POST['pass']); |
Latest revision as of 10:38, 8 December 2018
$check = hash('md5', $salt.$_POST['pass']); $stmt = $pdo->prepare('SELECT user_id, name FROM users WHERE email = :em AND password = :pw'); $stmt->execute(array( ':em' => $_POST['email'], ':pw' => $check)); $row = $stmt->fetch(PDO::FETCH_ASSOC); if ( $row !== false ) { $_SESSION['name'] = $row['name']; $_SESSION['user_id'] = $row['user_id']; // Redirect the browser to index.php header("Location: index.php"); return;