The HTTP 403 Forbidden error response is used when the server understood the request, but is refusing to fulfill it for some reason. This error is often encountered when entering a wrong username or password on a website.
Sometimes you may want to show a soft 403 Forbidden error, so that automated spam-bots gets confused. Soft errors will usually just send a 200 OK response instead of the real error – this is done to break certain bots and hacker tools.
Send a 403 from PHP
To send a 403 response from PHP, you can use the header function like this:
$Error_Page_Content = ''; header('HTTP/1.1 403 Forbidden'); echo $Error_Page_Content;
Note. If you want to deliver a custom error page, then it should be outputted after sending the headers. You should fill $Error_Page_Content with your own HTML.