how to save ckeditor text in database php?

Today, We want to share with you how to save ckeditor text in database php.In this post we will show you wysiwyg text editor with php and mysql, hear for how to save tinymce content in database php we will give you demo and example for implement.In this post, we will learn about How To Save Ckeditor Text In Database Laravel? with an example.

Integrate CKEditor to HTML page and save to MySQL with PHP

Table structure

CREATE TABLE `products_details` (
  `id` int(11) NOT NULL PRIMARY KEY AUTO_INCREMENT,
  `title` varchar(255) NOT NULL,
  `product_desc` text NOT NULL,
  `product_all_info` text NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

config.php

<?php

$host = "localhost"; /* Host name */
$user = "root"; /* User */
$password = ""; /* Password */
$dbname = "tutorial"; /* Database name */

$con = mysqli_connect($host, $user, $password,$dbname);
// Check connection
if (!$con) {
  die("Connection failed: " . mysqli_connect_error());
}

3. Download & Include

<script src="ckeditor/ckeditor.js" ></script>
//OR
<script src="//cdn.ckeditor.com/4.11.1/standard/ckeditor.js"></script>

HTML & PHP Code

<?php 
include "config.php";

// Insert Product record
if(isset($_POST['submit'])){

  $title = $_POST['title'];
  $product_desc = $_POST['product_desc'];
  $product_all_info = $_POST['product_all_info'];

  if($title != ''){

    mysqli_query($con, "INSERT INTO products_details(title,product_desc,product_all_info) VALUES('".$title."','".$product_desc."','".$product_all_info."') ");
    header('location: index.php');
  }
}

?>

<!DOCTYPE html>
<html>
  <head>
    <title>Integrate CKeditor to HTML page and save to MySQL with PHP - www.pakainfo.com</title>

    <!-- CSS -->
    <style type="text/css">
    .cke_textarea_inline{
       border: 1px solid black;
    }
    </style>

    <!-- CKEditor --> 
    <script src="ckeditor/ckeditor.js" ></script>
  </head>
  <body>

    <form method='post' action=''>
       Product Title : 
       <input type="text" name="title" ><br>

       Product Summury Description: 
       <textarea id='product_desc' name='product_desc' style='border: 1px solid black;' >       </textarea><br>

       Product Full Description: 
       <textarea id='product_all_info' name='product_all_info' ></textarea><br>

       <input type="submit" name="submit" value="Submit">
    </form>

  </body>
</html>

JavaScript Code

<script type="text/javascript">

// Initialize CKEditor
CKEDITOR.inline( 'product_desc' );

CKEDITOR.replace('product_all_info',{

  width: "600px",
  height: "400px"

}); 

</script>

I hope you get an idea about summernote save to database php.
I would like to have feedback on my infinityknow.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.