Salve, mi sapete dire perché non riesco ad fare l'accesso mi dice sempre "password sbagliata"?
ecco il codice:
La password lo salvata in questo modo:
Mi dite come posso fare? Grazie mille e buona giornata.
ecco il codice:
PHP:
<?php
include($_SERVER['DOCUMENT_ROOT'].'/inc.php');
$message = '';
if(isset($_POST["login"]))
{
if(empty($_POST["display"]))
{
echo "Non hai inserito la password";
}
else
{
$db = getDB();
$records = $db->prepare('SELECT * FROM admin WHERE pass = :pass');
$records->bindParam(':pass', $_POST["display"]);
$records->execute();
$results = $records->fetch(PDO::FETCH_ASSOC);
/* Qui deve esserci qualcosa che non mi fa verificare se la password se è giusta o no .. e poi ed solo una password numerica. */
if($records->rowCount() > 0 && password_verify($_POST["display"], $results['pass']) ){
session_start();
$_SESSION['name'] = $results['name'];
header("Location: home.php");
} else {
$message = 'Password sbagliata, riprovare.';
}
}
}
?><script>
function inserisci(numero) {
var valore = document.getElementById('display').value;
document.getElementById('display').value = valore + numero;
}
function cancella() {
var len = document.getElementById('display').value.length;
var str = document.getElementById('display').value.substr(0,len-1);
document.getElementById('display').value=str;
}
</script>
<?php echo $message; ?>
<form action="login2.php" method="post">
<table>
<tr>
<td colspan="3">
<input type="text" size="13" type="hidden" id="display" name="display" onload="focus()"/>
</td>
</tr>
<tr>
<td>
<input type="button" id="1" value="1" onclick="inserisci(this.value)"/>
</td>
<td>
<input type="button" id="2" value="2" onclick="inserisci(this.value)"/>
</td>
<td>
<input type="button" id="3" value="3" onclick="inserisci(this.value)"/>
</td>
</tr>
<tr>
<td>
<input type="button" id="4" value="4" onclick="inserisci(this.value)"/>
</td>
<td>
<input type="button" id="5" value="5" onclick="inserisci(this.value)"/>
</td>
<td>
<input type="button" id="6" value="6" onclick="inserisci(this.value)"/>
</td>
</tr>
<tr>
<td>
<input type="button" id="7" value="7" onclick="inserisci(this.value)"/>
</td>
<td>
<input type="button" id="8" value="8" onclick="inserisci(this.value)"/>
</td>
<td>
<input type="button" id="9" value="9" onclick="inserisci(this.value)"/>
</td>
</tr>
<tr>
<td>
<input type="button" id="C" value="C" onclick="cancella()"/>
</td>
<td>
<input type="button" id="0" value="0" onclick="inserisci(this.value)"/>
</td>
<td>
<input type="submit" id="login" name="login" value="Login"/>
</td>
</tr>
</table>
</form>
La password lo salvata in questo modo:
PHP:
$stmt->bindValue(':pass', password_hash("01050620014", PASSWORD_BCRYPT));
Mi dite come posso fare? Grazie mille e buona giornata.