Redirect not working in Slim framework 2.0
try{
$db->updatePassword($checkAuthentication['token_id'],$email,$password);
$res = $db->updatePassword($email,$password);
if($res['success'] == USER_PASSWORD_UPDATE_SUCCESSFULLY) {
$app->flash('message','Form submitted!');
$app->redirect($app->urlFor('thanks'));
}else{
$app->flash('errors', 'Error while updating password');
$app->redirect($app->urlFor('resetpassword',
array(
'encrypt_url' => $resetPasswordToken
)
));
}
} catch (Exception $ex) {
$app->flash('errors', $ex->getMessage());
$app->redirect($app->urlFor('resetpassword',
array(
'encrypt_url' => $resetPasswordToken
)
));
}
Here $app->redirect($app->urlFor('thanks'));
doesn't work, and goes to the catch
part.
We are use group for routing.
$app->group('/web', function () use ($app) {
// Version group
$app->group('/user', function () use ($app) {
$app->post('/updatepassword', function () use ($app) {
// our code
});
$app->get('/thanks', function () use ($app) {
$app->render('thanks.php', array(
'pageTitle' => 'Thanks page'
));
})->name('thanks');
});
});
Give me a suggestion to redirect to thanks page with flash success message .
If it goes to the catch
block then it means $db->updatePassword($checkAuthentication['token_id'],$email,$password);
throws an exception.
When that happens everything else following in the try {}
block gets skipped and execution goes to the catch{}
block.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.