I want to redirect to a page (error.php, for example) depending on the info in a form in my website. I managed to log an error like this:
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 it so it sends you to a page with that error in particular instead of logging/requesting it in the network tab?
Right now I get this:
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
Which is almost working as intended. What I want to do is for it to send me to "http://raspberrypi/chartAPI/error/406" (for example), and display the contents in a file called 406.php (or error406.php, or error.php or whatever call it).
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 is it removing {date2}? And why is it asking for a POST method?
This question is a continuation of this one, but due to how this website handles these "old" questions, mine got pushed down and regardless of how many edits I put, it doesn't get any attention anymore.