I want to redirect to the page (error.php or maybe 404 / 406.php, regardless of the error) 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?
Edit for further explanation . 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. What I want to do is send me to " http: // raspberrypi / chartAPI / error / 406 " (for example) and display the contents in a file called 406. php (or error406.php or whatever you want to name) .
Edit2: - :
return $response->withRedirect("error.php");
:
Request URL:http://raspberrypi/chartAPI/api/{id}/{date1}/error.php
Request Method:GET
Status Code:405 Method Not Allowed
slim :
Method not allowed. Must be one of: POST
{date2}? POST?