不幸的是我没有找到问题的解决方案我是初学者,我不知道为什么这个功能不起作用以及我将如何使用它。如果有人给我写的解决方案来理解代码和问题的问题。 (PS:dsl仅用于谷歌翻译)
(//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 for google translation)
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