title: How to submit HTML form using TinyMCE, jQuery and PDO? (full code)
body: <p>The <code>$_POST['reply']</code> variable contains html tags like <code>&lt;p&gt;text goes here&lt;/p&gt;</code> but I can not insert it into the database. For the <code>reply</code> I use the <strong>TinyMCE</strong> and when I do not use it (the input as no tags) like <code>text goes here</code> then it is inserted correctly.</p>
  
  <p>What am I missing here?</p>
  
  <pre><code>try {
      $db = new PDO(DB_DRIVER . ":dbname=" . DB_DATABASE . ";host=" . DB_SERVER, DB_USER, DB_PASSWORD, array(PDO::MYSQL_ATTR_INIT_COMMAND =&gt; "SET NAMES 'utf8'"));
      $db-&gt;setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  
      $stmt = $db-&gt;prepare("INSERT INTO replies(article_id, comment) VALUES (:article_id, :comment)");
  
      $stmt-&gt;bindParam(':article_id', $article_id, PDO::PARAM_INT);
      $stmt-&gt;bindParam(':comment', $_POST['reply'], PDO::PARAM_STR);
  
  
      if($stmt-&gt;execute()) {
        echo 'success';  
      }
  
      $db = null;
  } catch(PDOException $e) {
      trigger_error('Error occured while trying to insert into the DB:' . $e-&gt;getMessage(), E_USER_ERROR);
  }
  </code></pre>
  
  <p><strong>Here is the form code:</strong></p>
  
  <pre><code>&lt;form class="comment-form"&gt;
      &lt;div class="form-input"&gt;
          &lt;input type="hidden" name="post_id" value="&lt;?= $row['id']; ?&gt;" /&gt;
      &lt;/div&gt;
  
      &lt;div class="form-input"&gt;
          &lt;textarea name="reply" id="elm1" rows="8"  placeholder="Your comment here" &gt;&lt;/textarea&gt;
      &lt;/div&gt;
  
      &lt;div class="form-input"&gt;
          &lt;input type="Submit" class="btn btn-primary" id="submit" value="SEND" /&gt;
      &lt;/div&gt;
  &lt;/form&gt;
  
  &lt;script type="text/javascript"&gt;
      $(function(){
          $(".comment-form").submit(function(event){
              event.preventDefault();
              $("#results")
                  .show();
  
              $.post('add-it.php', $(".comment-form").serialize(), function(data) {
                  $('#submit')
                      .hide();
                  $('#results')
                      .html(data)
                      .fadeIn('slow');
              });
          });
      });
  &lt;/script&gt;
  </code></pre>