S
S
Sergey08082017-06-10 16:23:59
PHP
Sergey0808, 2017-06-10 16:23:59

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",
        ]
    );

This is a router.
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/>";
                }

           }


        }

This is the controller. Tell me where I'm making a mistake?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question