Frank Frank - 8 months ago 88
HTML Question

php form post content 403 error

It was recently brought to my attention by a user on my site that if they submitted this content on any form on my site, they are returned with a 403 error.

make a <hr> add this css to it hr{border:none; border-top:1px solid #000; background:none; height:1px; width:yourwidth;}


Here's the background of the form processing (it's not the actual code used on the site).

<?php


if (isset($_POST['test'])) {

echo htmlspecialchars($_POST['content']);

}

?>

<form action = "" method = "post">

<textarea name = "content"></textarea>
<input type = "submit" name = "test"/>

</form>


It all works fine, as long as the text above isn't submitted into the form.

I try changing the htmlspecialchars to htmlentities, strip_tags anything I could think of really but it still returns a 403 error. How can I prevent this 403 error?

Answer Source

I try your code. Anything seems to works fine. Have you try remove some parts of the content in textarea to see which part create this error? Note that 403 is an HTTP status code returned by a web server when a user requests a web page or media that the server does not allow them to access.

You can also ask your hosting provider if they have a security module that rejects the input because it considers it's an attempt to perform an attack.

Also : Have you tried to change the name of your textarea to something else than "content".

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download