Problem to save data with CKEDITOR PHP AND MYSQL


I'm trying to insert data from a CKEDITOR into a mysql database with php, but I'm trying to capture that data through different modes that I found on the web, but I can not insert the CKEDITOR content in a field of the BD: htmlentities, htmlspecialchars, but I do not know how I can capture and insert that data. I leave the code I use, and if you could help me achieve it.

//Primero a través de un js guardo los datos:

var editor= CKEDITOR.instances['editor'].getData();
//y así envío el dato con ajax y metodo GET 

Then in the PHP file, using the GET method to insert:

asked by Joseph Abdias Alejandro Tinoco 05.10.2016 в 02:48

4 answers


To capture the data of ckeditor , you can do it with php


<textarea name="texto" id="editor1"></textarea>


<script type="text/javascript">
    CKEDITOR.replace( 'editor1',
            lang: 'es',
            skin: 'office2013',
            allowedContent: true,
            ignoreEmptyParagraph: false,
            enterMode: CKEDITOR.ENTER_BR


    $contenido = addslashes($_POST['texto']);

And if you do it with ajax , it has to be by post


var data = $("#idFormulario").serialize();
      type: "POST",
      url: "url",
      data: data,
      success: function(data) {

answered by 07.10.2016 в 06:57

Ckeditor saves html if or if, make sure that the field where it is saved is preferably VARCHAR and do not apply any filter to the variable that receives the contents of the ckeditor, save it as is, that is, do not use htmlentities or anything like that and obviously send by POST.

answered by 12.10.2016 в 04:06

Have you already tried adding adds?

answered by 05.10.2016 в 20:05

Did you validate that your editor variable contains something? The first thing you should do is validate until part of your information is traveling; it is likely that you are not correctly capturing the control data.

answered by 07.10.2016 в 06:22