403 Forbidden When Posting HTML Tags

forms, php, wysiwyg

Solution

Assuming that the difference in the POST array is really just whether or not it has a tag in it (you should verify this by actually inspecting the POST and making sure that it's actually otherwise identical), I'm guessing this has to do with a software firewall (the 403 error is a tip-off that the problem is probably at the server level rather than the PHP level - though you may have a PHP file purposely sending 403 headers). Check to see if you have ModSecurity or something similar turned on. I suspect you may need to reconfigure your server's firewall, as they can be configured to reject specific tags, etc (specifically, check out `SecFilter` settings)

Problem

I have a form that I'm using the nicEdit WYSIWYG with the following buttons enabled: - Bold - Italicize - Underline - Unordered List I can submit the form and process the an update to my SQL database when any one of those is used EXCEPT for the unordered list. When the text field makes use of the UL I receive a 403 Forbidden error from the server. The form code looks is as follows: ``` <form action="actions.php?action=2" method="POST"> <p>How We Met Story</p> <textarea name="area1" cols="50" id="area1"><?php echo html_entity_decode($row_rsHowWeMet['howWeMet']); ?></textarea> <input name="websiteID" type="hidden" value="<?php echo $_GET['websiteID'] ?>" /> <p><input id="partyEntry" type="submit" name="Submit" value="Save Changes" /></p> </form> ``` And the code that processes the form is as follows: ``` $myMessage = htmlentities($_POST['area1']); $sql2 = "UPDATE `tools_wedWebHowWeMet` SET `howWeMet` = '" . $myMessage . "' WHERE websiteID = '" . $_POST['websiteID'] . "'"; if (!mysql_query($sql2,$con)) { echo "failed"; die('Error: ' . mysql_error()); } ``` Any ideas why this is happening? I've done some searching around and haven't found a solid answer. There was another thread on StackOverflow with a very similar issue but no answers. Thanks very much.

Original source