不幸的是,我沒有找到解決問題的方法,我是一個初學者,我不知道爲什麼這個函數不起作用,我將如何使用它。如果有人給我寫解決方案,請理解代碼和問題。 (PS:DSL只是谷歌翻譯)password_verify()不起作用
(//Really 20 hours I try. No solution...(page login)
if (isset($_POST['connexion']))
{ $pseudoconnect=htmlspecialchars($_POST['pseudoconnect']);
$passwordconnect=htmlspecialchars($_POST['passwordconnect']);
if (!empty('$pseudoconnect') AND !empty('$passwordconnect'))
{
$pseudoconnectlenght=strlen($pseudoconnect) ;
$passwordconnectlenght=strlen($passwordconnect) ;
if ($pseudoconnectlenght<3 || $pseudoconnectlenght>10 || $passwordconnectlenght<3 || $passwordconnectlenght >10)
{
echo "remplis tous les infos exacte";
}
else
{
$repnom = $connect->prepare("SELECT password FROM membres WHERE pseudo=? ");
$repnom->execute(array($passwordconnect));
$userinfo= $repnom->fetch();
$_SESSION['password']= $userinfo['password'];
if (password_verify($_POST['passwordconnect'], $userinfo['password']))
{
echo "valid";
} else {
echo "pas valid";}}}
(頁面登記工作正常)我用password_hash
其功能以及.. PS:DSL只是谷歌翻譯)
if (isset($_POST['envoyer']))
{
if (!empty($_POST['pseudo']) AND !empty($_POST['password']))
{
$pseudo=htmlspecialchars($_POST['pseudo']);
$password=htmlspecialchars($_POST['password']);
//$password=password_hash('password',PASSWORD_DEFAULT,['cost'=>12]);
$pseudolenght=strlen($pseudo);
$passwordlenght=strlen($password);
/*verifier les champs */
if ($pseudolenght<4 ||$pseudolenght>10 || $passwordlenght<4 || $passwordlenght> 10)
{
echo "pass ou pseudo pas correct";
}
else //enregistrement et verifier pseudo
{
$repetepseudo = $connect->prepare("SELECT * FROM membres WHERE pseudo=?");
$repetepseudo->execute(array($pseudo));
$existpseudo = $repetepseudo->rowCount();
//verifier pseudo si déja existe
if ($existpseudo == 0)
{
//hasher password
$hash=password_hash($password,PASSWORD_DEFAULT,['cost'=>12]);
$sql = "INSERT INTO membres (pseudo,password) VALUES (?,?)";
$query = $connect->prepare($sql);
$query->execute(array($pseudo,$hash));
echo "enregistrement valide";
//header('location: html.php');
}
else
{
echo "déja utiliser";
}
}
} //if empty
else {
echo "remplir tous les champs ";
}
}//if isset eenvoyer
對不起創建代碼不爲我 –
過去的代碼在這裏工作,沒有圖片... – Rasclatt
還什麼不起作用,這是一個廣泛的聲明 – Rasclatt