note 124255 added to function.crypt

From: Date: Tue, 01 Oct 2019 07:28:51 +0000
Subject: note 124255 added to function.crypt
Groups: php.notes 
Request: Send a blank email to php-notes+get-212445@lists.php.net to get a copy of this message
je voudrais avoir un aide pour la ligne de comparaison d'un mot de passe crypté et celui non crypté.ça me renvoie toujours que le" Invalid username and password!" MECI POUR VOTRE AIDE <?php $msg = ""; if(isset($_POST['submitBtnLogin'])) { $username = trim($_POST['username']); $password = trim($_POST['password']); //$pass_crypt = crypt($password); if($username != "" && $password != "") try { $query = "select * from chambre where Matricule=:username and password=:password"; $stmt = $db->prepare($query); $stmt->bindParam('username', $username, PDO::PARAM_STR); $stmt->bindValue('password', $password, PDO::PARAM_STR); $stmt->execute(); $count = $stmt->rowCount(); $row = $stmt->fetch(PDO::FETCH_ASSOC); if($count == 1 && !empty($row)) { if (hash_equals($hashed_password, crypt($_POST['password'], $hashed_password))) { echo "Mot de passe correct !"; /******************** Your code ***********************/ $_SESSION['sess_user_id'] = $row['id']; $_SESSION['sess_user_name'] = $row['username']; $_SESSION['sess_name'] = $row['name']; header("location: home.php"); } else { echo'<script>alert("Invalid password!")</script>'; } } else { echo'<script>alert("Invalid username and password!")</script>'; } } catch (PDOException $e) { echo "Error : ".$e->getMessage(); } } else { $msg = "Both fields are required!"; } ?> ---- Server IP: 208.43.231.9 Probable Submitter: 185.85.3.195 (proxied: 154.117.200.190) ---- Manual Page -- http://php.net/manual/en/function.crypt.php Edit -- https://master.php.net/note/edit/124255 Del: integrated -- https://master.php.net/note/delete/124255/integrated Del: useless -- https://master.php.net/note/delete/124255/useless Del: bad code -- https://master.php.net/note/delete/124255/bad+code Del: spam -- https://master.php.net/note/delete/124255/spam Del: non-english -- https://master.php.net/note/delete/124255/non-english Del: in docs -- https://master.php.net/note/delete/124255/in+docs Del: other reasons-- https://master.php.net/note/delete/124255 Reject -- https://master.php.net/note/reject/124255 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#212445) next »