Answer the question
In order to leave comments, you need to log in
Php Phalcon how to redirect user after registration?
I want to redirect the user after registering to his page, that is, the address bar should get localhost/users/show/Sergey, the redirect to the user's page occurs, but the address bar remains - localhost/users/register.
$router->add(
"/users/show/{name}",
[
"controller" => "users",
"action" => "show",
]
);
public function registerAction()
{
$user = new Users();
// Store and check for errors
$success = $user->save(
$this->request->getPost(),
[
"name",
"email",
]
);
if ($success) {
$this->flash->success("Вы зарегистрированы");
return $this->dispatcher->forward(
[
"controller" => "users",
"action" => "show",
"params" => [$user->name]
]
);
} else {
echo "Произошли следующие проблемы: ";
$messages = $user->getMessages();
foreach ($messages as $message) {
echo $message->getMessage(), "<br/>";
}
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question