2
I sent this link to a user’s email:
http://www.example.com/redefinir_senha.php?token=4kl_EIwmivsCg52TsBgWWgWMPsApjFTJL8oBUXPDoHE&uid=USER-ID
On the page reset.php password I know how to do the following:
$token= $_GET['token'];
The deal is that before using the "token" to do the password update with my dbupdate function i need to get the new form password that is on this page also through the POST method.
I have used GET before and within this IF below, but at the end the password is not changed in the database.
if ($_SERVER["REQUEST_METHOD"] == "POST"){
$token = $_GET['token']; // Já coloquei aqui e fora, já tentei usar sessão
// ao invés de simples variável e nada...
if (isset($_POST['senha'])){$senha = DBEscape($_POST['senha']);
$ativar = array('senha' => $senha);
$atualiza = DBUpdate('myway', $ativar, "token = '$token'");
if ($atualiza==true){
echo "Senha redefinida com sucesso!";
}
} else {
echo "Ocorreu um erro, entre em contato conosco!<br>";
}
}
No problem with the update function as I am using it on another page and works normally.
If within my Update function me just switch "token = '$token'"
for "email = '[email protected]'"
everything works...
Is the token not coming with the correct password change? How is
action
form? If you are not using thesubmit
of the form, adding thetoken
in AJAX?– Wakim
action="<? php echo htmlspecialchars($_SERVER["PHP_SELF"]);? >" This action I need to post the password on the same page. The token comes from the link the user clicks in the email.
– I Wanna Know
To
Query String
appears in theaction
? Based on the question: http://stackoverflow.com/questions/20127113/php-serverphp-self-to-include-query-string, thePHP_SELF
does not return toQuery String
, try to use theREQUEST_URI
as recommended.– Wakim
I looked there but do not know how to apply. Use request instead of post?
– I Wanna Know
No no no, just change the
$_SERVER['PHP_SELF']
for$_SERVER['REQUEST_URI']
in theaction
form. So do not lose the Query String that contains the token.– Wakim
Man, it worked. Thank you! How it works?
– I Wanna Know
I’ll create an answer and explain ok?
– Wakim
Thanks! Tav'squeezing my mind that...
– I Wanna Know