How do I sanitize text input with PHP?-ThrowExceptions

Exception or error:

I have a textarea that receives input from the user and I am using htmlspecialchars($_POST['bio']); to sanitize the input.

Whenever I try to test the following input: <script>alert('1');</script>
It works as expected on my local dev machine but when I test it on a webhosting server I get the following error:

Forbidden You don’t have permission to access this resource.

Additionally, a 403 Forbidden error was encountered while trying to
use an ErrorDocument to handle the request.

What I mean by sanitizing input is basically I want to disallow injected javascript code. So writing <script>alert('1');</script should display in plain text and not execute code to show an alert box. Instead of displaying in plain text, I get a 403 forbidden error.

How to solve:

Leave a Reply

Your email address will not be published. Required fields are marked *