How to redirect the same page

hi
i have a functio to send a mail from the site with filds

how i do that when i send the msg mail i stay in the same page and not go to other page?

return $response->withRedirect('http://example.com');

Depending what you might be using for a view layer or template you can likely specify the location by name. If you are using Slim-Twig:

return $response->withRedirect($this->router->pathFor('routeName'));

thank but i dont know what a conroller send th form

again:

i have thr same form in a 4 pages
when i send the form i return to other routeName
but i when to stay in the same page and not Redirect to other

Do you want to stay on the same page by using an Ajax call? Otherwise you would just return the response with the page you would like.

u can help me and show me exmple
plz with a form with name and phone to send to controller

I’m not sure I understand what you are trying to accomplish. Here is a (not very secure) example of a controller method that would accept an email and phone number from a form, send an email, and then send the user back to a specific page.

    public function mailPhoneAction($request, $response, $args)
    {
        $emailAddress = $request->getParsedBodyParam('email_address');
        $phoneNumber = $request->getParsedBodyParam('phone_number');
        mail($emailAddress, 'Your Phone Number', "Your phone number is $phoneNumber");
        return $response->withRedirect('http://example.com');
    }

that i know
but how i do with ajax??
to stay at the same page after i do a submit ?

I haven’t used Slim with Ajax requests. I don’t believe there is anything really peculiar versus other packages, but hopefully someone else will chime in.