title: Forbidden Error When Submitting Simple PHP Form
body: <p>I have a non complicated issue......that seems to be more complicated than it should be.</p>
  
  <p>I have a simple form that is used to add content to a website. Some of the fields need to have html inputted into them. However, when you input certain html elements into the different parts of the form, it decides that it hates you and throws a forbidden 403 error. Here is the form below:</p>
  
  <pre><code>&lt;?php
      $data = f("SELECT * FROM table WHERE id = '{$_GET['id']}'");
  ?&gt;
  &lt;form action="&lt;?=$_SERVER['PHP_SELF']?&gt;?id=&lt;?=$_GET['id']?&gt;&amp;action=edit" method="post"&gt;
      &lt;table cellspacing="0" cellpadding="2" border="0"&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;b&gt;Title:&lt;/b&gt;&lt;/td&gt;
              &lt;td&gt;&lt;input type="text" name="title" style="width: 300px;" value="&lt;?=$data['title']?&gt;" /&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;b&gt;URL:&lt;/b&gt;&lt;/td&gt;
              &lt;td&gt;&lt;input type="text" name="url" style="width: 300px;" value="&lt;?=$data['url']?&gt;" /&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;b&gt;Sub-Category:&lt;/b&gt;&lt;/td&gt;
              &lt;td&gt;
                  &lt;select name="subCategoryId"&gt;
                      &lt;option value=""&gt;&lt;/option&gt;
                      &lt;option value="1"&gt;A&lt;/option&gt;
                      &lt;option value="2"&gt;B&lt;/option&gt;
  
                  &lt;/select&gt;
              &lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;b&gt;Short Description:&lt;/b&gt;&lt;/td&gt;
              &lt;td&gt;&lt;textarea name="shortDescription" rows="6" cols="60"&gt;&lt;?=$data['shortDescription']?&gt;&lt;/textarea&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;b&gt;Template:&lt;/b&gt;&lt;/td&gt;
              &lt;td&gt;&lt;textarea name="template" rows="6" cols="60"&gt;&lt;?=$data['template']?&gt;&lt;/textarea&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;b&gt;Ads:&lt;/b&gt;&lt;/td&gt;
              &lt;td&gt;&lt;textarea name="ads" rows="6" cols="60"&gt;&lt;?=$data['ads']?&gt;&lt;/textarea&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;b&gt;Keywords:&lt;/b&gt;&lt;/td&gt;
              &lt;td&gt;&lt;textarea name="keywords" rows="6" cols="60"&gt;&lt;?=$data['keywords']?&gt;&lt;/textarea&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;b&gt;Questions:&lt;/b&gt;&lt;/td&gt;
              &lt;td&gt;&lt;textarea name="questions" rows="6" cols="60"&gt;&lt;?=$data['questions']?&gt;&lt;/textarea&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;b&gt;Salary:&lt;/b&gt;&lt;/td&gt;
              &lt;td&gt;&lt;textarea name="salary" rows="6" cols="60"&gt;&lt;?=$data['salary']?&gt;&lt;/textarea&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;b&gt;Jobs:&lt;/b&gt;&lt;/td&gt;
              &lt;td&gt;&lt;textarea name="jobs" rows="6" cols="60"&gt;&lt;?=$data['jobs']?&gt;&lt;/textarea&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;b&gt;Meta Description:&lt;/b&gt;&lt;/td&gt;
              &lt;td&gt;&lt;input type="text" name="metaDescription" style="width: 300px;" value="&lt;?=$data['metaDescription']?&gt;" /&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;b&gt;Meta Keywords:&lt;/b&gt;&lt;/td&gt;
              &lt;td&gt;&lt;input type="text" name="metaKeywords" style="width: 300px;" value="&lt;?=$data['metaKeywords']?&gt;" /&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&amp;nbsp;&lt;/td&gt;
              &lt;td&gt;&lt;input type="submit" name="submit" value="Edit Job" /&gt;&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/table&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>I have other forms that follow this same pattern without any trouble. To further make this even more confusing, it will only throw this error when any 2 html elements are supplied in the text area (it handles one html element just fine). The text areas are ads, keywords, salaries, and jobs. The other text areas will take it just fine, but these 4 won't. If I can make this one more bit confusing, if I simple enter in text in those fields and save it, it runs without a problem.</p>
  
  <p>To handle the post data, I only use mysql_real_escape_string() to handle the data, I don't do a strip_tags() as I need the html in there.</p>
  
  <p>Is this a weird apache error that can be fixed with .htaccess? Is there a module in PHP that is conflicting with this? </p>
  
  <p>-------EDIT HERE IS THE ANSWER--------</p>
  
  <p>Ben brought up a fantastic answer that is probably the problem and I cannot fix it because of a lack of privileges. So I created an onsubmit event from an idea that Gerben gave me and wrote the following javascript.</p>
  
  <pre><code>function awesome() {
          elements = document.forms[0].elements;
          for(var i = 0; i &lt; elements.length; i++) {
              switch(elements[i].name) {
                  case "ads":
                  case "shortDescription":
                  case "template":
                  case "questions":
                  case "salary":
                  case "jobs":
                      str = elements[i].value;
                      elements[i].value = str.replace(/&lt;/g,"#@!");
                      break;
              }
          }
          return true;    
      }
  </code></pre>
  
  <p>Then on the receiving end, I did a str_replace to replace #@! back to a &lt; and that at least made the thing work.</p>
  
  <p>I'm on a horse....hyaa!</p>
  
  <p>Thanks for all your help. :)</p>