Redirecting to another error page in Slim Framework

I want to redirect to a page (e.g. error.php) depending on the information in the form on my website. I managed to register the following error:

if ($date > $curdate) {
    return $response
        ->withStatus(406)
        ->withHeader('Content-Type', 'text/html')
        ->write('You can\'t select dates in the future!');
}

How can I do this so that he sends you to a page with this error, in particular, instead of registering / requesting it on the network tab?

Now I get the following:

Request URL:http://raspberrypi/chartAPI/api/{id}/{date1}/{date2}
Request Method:POST
Status Code:406 Not Acceptable
Remote Address:192.168.0.80:80
Referrer Policy:no-referrer-when-downgrade

It almost works as intended. I want to do this in order to send me to " http: // raspberrypi / chartAPI / error / 406 " (for example) and display the contents in a file named 406.php (or error406.php, or error.php or something else )

I managed to do something with this:

return $response->withRedirect("error.php");

But I get this:

Request URL:http://raspberrypi/chartAPI/api/{id}/{date1}/error.php
Request Method:GET
Status Code:405 Method Not Allowed

And slim throws this error:

Method not allowed. Must be one of: POST

Why does he delete {date2}? And why does he request the POST method?

, - , - "" , , .

+4
1

withRedirect, URL- ,

GET, POST

, , , GET, POST ,

, POST , URL?!

+1

Source: https://habr.com/ru/post/1675686/


All Articles