-1
When registering on the site, the user receives an email activation of the registration, until then all right. The problem is in checking the password_hash, I know you have password_verify, but in this case it seems that it is not possible to use it. The $key variable takes the encrypted user id using password_hash.
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Email de confirmação</title>
</head>
<body>
<?php
$key = filter_input(INPUT_GET, 'key', FILTER_SANITIZE_SPECIAL_CHARS);
$verify = $conexao->prepare("select * from user where password_hash(id) = '$key'");
$verify->execute();
if($verify){
$id = $verify->fetch(PDO::FETCH_OBJ);
$confirm = $conexao->prepare("update user set confirm = 1 where id = :id");
$confirm->bindValue(':id', $id->id, PDO::PARAM_INT);
$confirm->execute();
echo 'Cadastro ativado com sucesso!';
}else{
echo 'Erro ao ativar cadastro';
}
?>
</body>
</html>
As shown above, I tried to verify the user id in the database, thus:
$verify = $conexao->prepare("select * from user where password_hash(id) = '$key'");
And that way too:
$verify = $conexao->prepare("select * from user where password_hash(id, PASSWORD_DEFAULT) = '$key'");
But as expected gave error: 'Syntax error or access Violation: 1305 FUNCTION password_hash does not exist', vi que dá para fazer assim com o MD5. You can do something like this with password_hash?
The error is in your Query,
password_hash
is a PHP function, so it is giving the syntax error. Do the following, take the email to which the activation message was sent, from which you take the$id
registered and uses thepassword_verify
with the$key
– Leandro
password_hash
is a PHP function. It won’t work even within a query. Maybe this https://answall.com/a/147319/4751 will help you.– gmsantos
For it is Leandro, but if I do as MD5, so for example: $Verify = $connected->prepare("select * from user Where MD5(id) = '$key'"); Works normal. wanted to know if you have any function for password_hash to work inside a query, if not I do with MD5 even.
– Luizinho