🕷️ Crawler Inspector

URL Lookup

Direct Parameter Lookup

Raw Queries and Responses

1. Shard Calculation

Query:
Response:
Calculated Shard: 19 (from laksa061)

2. Crawled Status Check

Query:
Response:

3. Robots.txt Check

Query:
Response:

4. Spam/Ban Check

Query:
Response:

5. Seen Status Check

ℹ️ Skipped - page is already crawled

📄
INDEXABLE
CRAWLED
4 hours ago
🤖
ROBOTS ALLOWED

Page Info Filters

FilterStatusConditionDetails
HTTP statusPASSdownload_http_code = 200HTTP 200
Age cutoffPASSdownload_stamp > now() - 6 MONTH0 months ago
History dropPASSisNull(history_drop_reason)No drop reason
Spam/banPASSfh_dont_index != 1 AND ml_spam_score = 0ml_spam_score=0
CanonicalPASSmeta_canonical IS NULL OR = '' OR = src_unparsedNot set

Page Details

PropertyValue
URLhttps://www.tiny.cloud/blog/save-content-database/
Last Crawled2026-04-07 00:17:37 (4 hours ago)
First Indexed2023-06-20 11:27:53 (2 years ago)
HTTP Status Code200
Meta TitleHow to save content to database | TinyMCE
Meta DescriptionLearn how to seamlessly save TinyMCE content to a database using PHP and SQLite. Follow our comprehensive tutorial for efficient database integration with the powerful TinyMCE editor.
Meta Canonicalnull
Boilerpipe Text
Databases are all around us, and without them websites and applications wouldn’t work. Since they’re so vital to online applications, why would components included in those applications – components that claim to speed up development – cause more problems and frustration by blocking database connections? For instance, the rich text editor component of an application lives at the center of content creation apps. A valuable rich text editor provides a fast and easy flow of content from the editor to the database without any roadblocks. Speed and efficiency are a part of best practice for database content management. TinyMCE is an trusted rich text editor that allows you to save content to a database without obstacles. It’s just one example of the many ways TinyMCE is easy to implement, and this post shows you how to save TinyMCE content to a database. What is database content management? Database content management is the ability to store and serve content from the database, to anywhere it’s needed in an application. When database content management is done effectively, it shows at the very least, the following practices: Allows for storage of a variety of digital content, including images, text, video, and audio files Fast and effective storage and retrieval Follows a standardized naming convention Connects metadata to each item in the database, providing information to identify content Plans for storage that fits the content, such as local storage, or cloud based storage. Plus, there’s more to consider before testing out a database for content management. Once you’re ready, the following sections explain the steps to save TinyMCE content to a database using an SQLite demo. How to save TinyMCE content to a database with PHP The first step is getting TinyMCE working. The following demo is based on the TinyMCE CMS solution . There are some prerequisites to know about before running the demo: Experience with HTML and JavaScript Familiarity with PHP, including prepared statements A text editor to adjust file content Access to the command line through bash or another shell Getting TinyMCE started In your development environment, create a new directory for the demo, create an index.html file in that directory. Also set up two more folders in the new directory, one for scripts, and one for PHP: mkdir demoApp/ cd demoApp/ touch index.html mkdir scripts/ mkdir php/ Change into the scripts folder and create a new JavaScript file for the TinyMCE configuration, which is set up in step 5 of this procedure: cd scripts/ touch tinymceConfig.js Change out of the scripts folder and then in the main directory, open the index.html file. Add the following starter HTML: <!DOCTYPE html> <html lang="en"> <head>  <meta charset="utf-8">  <meta name="viewport" content="width=device-width, initial-scale=1">  <script src="https://code.jquery.com/jquery-3.7.0.js"></script>  <script src="https://cdn.tiny.cloud/1/no-api-key/tinymce/6/tinymce.min.js" referrerpolicy="origin"></script>  <script src="scripts/tinymceConfig.js"></script> </head> <body>  <h1>TinyMCE CMS Starter Config</h1>  <textarea>    <h1>Visiting Norway</h1>     <p><strong><img style="float: right;" src="https://images.pexels.com/photos/1559825/pexels-photo-1559825.jpeg?auto=compress&amp;cs=tinysrgb&amp;dpr=2&amp;h=750&amp;w=1260" alt="Town" width="300" height="375"></strong>Norway, officially the Kingdom of Norway, is a <a href="https://en.wikipedia.org/wiki/Nordic_countries">Nordic country</a> in Northern Europe, the mainland territory of which comprises the western and northernmost portion of the Scandinavian Peninsula.</p>     <p>The remote Arctic island of Jan Mayen and the archipelago of Svalbard also form part of Norway. Bouvet Island, located in the <a href="https://en.wikipedia.org/wiki/Subantarctic">Subantarctic</a>, is a dependency of Norway; it also lays claims to the Antarctic territories of Peter I Island and Queen Maud Land. The capital and largest city in Norway is <a href="https://en.wikipedia.org/wiki/Oslo">Oslo</a>.<strong><br></strong></p>    <p>Listen to Norway's royal anthem on Spotify:</p>     <div style="left: 0px; width: 100%; height: 152px; position: relative; max-width: 650px;" data-ephox-embed-iri="https://open.spotify.com/track/6SPocux2pBpFp3lshAOek1?si=907d52cf2af94efc"><iframe style="top: 0; left: 0; width: 100%; height: 100%; position: absolute; border: 0;" src="https://open.spotify.com/embed/track/6SPocux2pBpFp3lshAOek1?utm_source=oembed" allow="clipboard-write; encrypted-media; fullscreen; picture-in-picture;" allowfullscreen="allowfullscreen"></iframe></div>    <h2>Geography</h2>    <p>Norway has a total area of 385,207 square kilometres (148,729 sq mi) and had a population of 5,425,270 in January 2022. The country shares a long eastern border with Sweden at a length of 1,619 km (1,006 mi). It is bordered by Finland and Russia to the northeast and the Skagerrak strait to the south, on the other side of which are Denmark and the United Kingdom.</p>    <p>Norway has an extensive coastline, facing the North Atlantic Ocean and the Barents Sea. The maritime influence dominates Norway's climate, with mild lowland temperatures on the sea coasts; the interior, while colder, is also significantly milder than areas elsewhere in the world on such northerly latitudes. Even during polar night in the north, temperatures above freezing are commonplace on the coastline. The maritime influence brings high rainfall and snowfall to some areas of the country.</p>    <p><em>Featuring <a href="https://en.wikipedia.org/wiki/Norway">content from Wikipedia</a></em></p>  </textarea> </body> </html> Add a link to TinyMCE through the CDN in the head section of the document, and a link to the TinyMCE configuration file:  <script src="https://cdn.tiny.cloud/1/no-api-key/tinymce/6/tinymce.min.js" referrerpolicy="origin"></script>   <script src="scripts/tinymceConfig.js"></script> Note: The CMS demo makes use of several Premium plugins. When you sign up for a FREE TinyMCE API key , you get free access to all Premium plugins for 14 days from when you replace the “no-api-key” string with your own TinyMCE API key. Adding the key also removes any domain name related errors appearing in the text area.  Change back into the scripts/tinymceConfig.js file, open it, and add the following JavaScript content to get TinyMCE started: tinymce.init({ selector: "#editor", plugins: "a11ychecker advcode advlist advtable anchor autocorrect autosave editimage image link linkchecker lists media mediaembed pageembed powerpaste searchreplace table template tinymcespellchecker typography visualblocks wordcount", toolbar: "undo redo | styles | bold italic underline strikethrough | align | table link image media pageembed | bullist numlist outdent indent | spellcheckdialog a11ycheck typography code", height: 540, a11ychecker_level: "aaa", typography_langs: ["en-US"], typography_default_lang: "en-US", advcode_inline: true, content_style: `        body {          font-family: 'Roboto', sans-serif;          color: #222;        }        img {          height: auto;          margin: auto;          padding: 10px;          display: block;        }        img.medium {          max-width: 25%;        }        a {          color: #116B59;        }        .related-content {          padding: 0 10px;          margin: 0 0 15px 15px;          background: #eee;          width: 200px;          float: right;        }      `, }); Save the changes, and then change back into the main directory. Test out the demo by opening the index.html file in a browser, or by running a localhost test with the Python command, or PHP command : Getting the database connection established Change into the scripts folder, and add the following JavaScript to the TinyMCE init script after the content_style option. It uses the TinyMCE setup option to listen for the change event. The change event registers when the editor loses focus, or the writer presses the Enter key. When the event happens, the jQuery gets the rich text editor content, and posts it onward to the database handler file. This content is what saves TinyMCE content to the database:    setup: (editor) => {        editor.on('change', (e) => {          $.ajax({            type: 'POST',            url: 'php/save.php',            data: {              editor: tinymce.get('editor').getContent()            },            success: function(data){              $('#editor').val('');              console.log(data)            }          })        })       }, Change back to the main directory, and then change into the php folder. Create a new PHP file for handling interactions with the database: touch connect.php Add the following PHP content to the connection file. This receives the editor content, and then saves the TinyMCE content to a database file: <?php $connect=new SQLite3('tinymceContent.db') or die("Could not connect to database, and save TinyMCE content"); $db="CREATE TABLE IF NOT EXISTS `Content`(id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, Content TEXT)"; $connect->exec($db); ?> Save the changes, and then close the .php file. Create a second .php file to handle the process of inserting and saving TinyMCE content into the database, and then add the following PHP content: touch save.php ... <?php require_once 'connect.php'; $editorContent=$_POST['editor']; $stmt = $connect->prepare("INSERT INTO `Content` (Content) VALUES (:Content)"); $stmt->bindParam(':Content', $editorContent); $stmt->execute(); echo "Save Data"; ?> Save the changes. Saving TinyMCE content to the database file with PHP and SQLite In the browser, refresh the demo, and try entering some new content into the TinyMCE text area, and then clicking away from the editor or pressing the Enter key. If the PHP content is working, you’ll see a 200 status code on the command line (if you’re running the demo with a localhost for tests with Python or PHP): [<date and time>] [::1]:60003 [200]: GET / [<date and time>] [::1]:60003 Closing [<date and time>] [::1]:60003 [200]: GET /tinymceConfig.js [<date and time>] [::1]:60003 Closing [<date and time>] [::1]:60003 Accepted [<date and time>] [::1]:60003 [200]: POST /php/save.php [<date and time>] [::1]:60003 Closing The successful command line content (code 200) indicates that the database file has been created in the php folder following the steps set in the connect.php file. Navigate into the php folder, and then open the tinymceContent.db database file with the SQLite command: sqlite3 tinymceContent.db  Query the database Content table to see the TinyMCE content saved in the database: SELECT * FROM Content; … 1|<h1>Visiting Norway</h1> <p><strong><img style="float: right;" src="https://images.pexels.com/photos/1559825/pexels-photo-1559825.jpeg?auto=compress&amp;cs=tinysrgb&amp;dpr=2&amp;h=750&amp;w=1260" alt="Town" width="300" height="375"></strong>Norway, officially the Kingdom of Norway, is a <a href="https://en.wikipedia.org/wiki/Nordic_countries">Nordic country</a> in Northern Europe, the mainland territory of which comprises the western and northernmost portion of the Scandinavian Peninsula.</p> ... Exit the database using the .quit command Next steps for saving TinyMCE content in a database You can rapidly get content from the editor, and save TinyMCE content to a database making use of the process explained in the previous sections. In production, the pattern of collecting data with the TinyMCE Get method, and binding parameters in prepared statements represent consistent patterns you can make use of for your project. For more on getting a CMS ready using TinyMCE, check out the tutorial on creating a CMS with TinyMCE to rival the major content management providers out there!
Markdown
Products [TinyMCEThe world's most trusted WYSIWYG HTML editor, for total control over your rich text editing.](https://www.tiny.cloud/tinymce/) - [Overview](https://www.tiny.cloud/tinymce/) - [Features](https://www.tiny.cloud/tinymce/features/) - [Pricing](https://www.tiny.cloud/pricing/) - [Documentation](https://www.tiny.cloud/docs/tinymce/latest/) - [Demos](https://www.tiny.cloud/docs/tinymce/latest/full-featured-premium-demo/) [MoxieManagerMedia file management simplified in a PHP or .NET environment.](https://www.tiny.cloud/moxiemanager/) [DriveFile and image management directly in the cloud.](https://www.tiny.cloud/drive/) [Start trial](https://www.tiny.cloud/auth/signup/ "Start trial") Developers [Developer CenterExplore frameworks, solutions, and technical guides for building with TinyMCE.](https://www.tiny.cloud/developer-center/) - [Frameworks](https://www.tiny.cloud/developer-center/frameworks/) - [Use Cases](https://www.tiny.cloud/developer-center/use-cases/) [Support](https://www.tiny.cloud/docs/tinymce/latest/support/) - [License Keys](https://www.tiny.cloud/docs/tinymce/latest/license-key/) - [Editor Loads](https://www.tiny.cloud/docs/tinymce/latest/understanding-editor-loads/) - [Submit a Support Request](https://support.tiny.cloud/hc/en-us/) [DocumentationIn-depth documentation to help you develop with and customize Tiny products.](https://www.tiny.cloud/docs/tinymce/latest/) - [Getting Started](https://www.tiny.cloud/docs/tinymce/latest/getting-started/) - [Basic Setup](https://www.tiny.cloud/docs/tinymce/latest/basic-setup/) - [API Reference](https://www.tiny.cloud/docs/tinymce/latest/apis/tinymce.root/) - [Migrating to TinyMCE](https://www.tiny.cloud/migrate-to-tinymce/) - [Download TinyMCE Free](https://www.tiny.cloud/get-tiny/) [Start trial](https://www.tiny.cloud/auth/signup/ "Start trial") Solutions [Use CasesOut-of-the-box editor with infinite use cases and complete design flexibility.](https://www.tiny.cloud/solutions/) - [Content Management System](https://www.tiny.cloud/solutions/cms-editor/) - [Email and Messaging Platform](https://www.tiny.cloud/solutions/wysiwyg-email-editor/) - [Document Management System](https://www.tiny.cloud/solutions/dms-editor/) - [Customer Relationship Management](https://www.tiny.cloud/solutions/crm-editor/) - [Learning Management System](https://www.tiny.cloud/solutions/lms-editor/) - [Internal & SaaS Applications](https://www.tiny.cloud/solutions/saas-applications-editor/) - [Workflow & Collaboration](https://www.tiny.cloud/solutions/workflow-management-editor/) [Roles](https://www.tiny.cloud/html-text-editor-for-developers/) - [Developer](https://www.tiny.cloud/html-text-editor-for-developers/) - [Product Manager](https://www.tiny.cloud/html-text-editor-for-product-managers/) - [Senior Manager](https://www.tiny.cloud/html-text-editor-for-scaling-and-monetizing/) [Security](https://www.tiny.cloud/tinymce/security/)[Hosting](https://www.tiny.cloud/solutions/on-premise-or-cloud-based-text-editor/)[Customization](https://www.tiny.cloud/solutions/customize-text-editor/)[Frameworks & Integrations](https://www.tiny.cloud/solutions/editor-framework-integration/) [Start trial](https://www.tiny.cloud/auth/signup/ "Start trial") Resources [BlogRead the world's best blog on WYSIWYG HTML editors, rich text editing, and insights on building SaaS application editors.](https://www.tiny.cloud/blog/) [Events & WebinarsExplore upcoming and on-demand events and webinars to unlock the full potential of TinyMCE.](https://www.tiny.cloud/events-and-webinars/) [Case StudiesDiscover why industry leaders and scaling start-ups love, use and trust Tiny products.](https://www.tiny.cloud/customer-stories/) [White Papers and ReportsSee how Tiny improves ROI, grows revenue and saves development costs.](https://www.tiny.cloud/resources/) Read: - [Buy vs Build: The Great Debate White Paper](https://www.tiny.cloud/buy-vs-build-whitepaper/) - [Opportunity Cost of Technical Debt](https://www.tiny.cloud/technical-debt-whitepaper/) - [The State of Rich Text Editors 2025 Report](https://www.tiny.cloud/developer-survey-results/) [Start trial](https://www.tiny.cloud/auth/signup/ "Start trial") [Pricing](https://www.tiny.cloud/pricing/)[Contact Us](https://www.tiny.cloud/contact/) [Log In](https://www.tiny.cloud/auth/login/)[Start Free Trial](https://www.tiny.cloud/auth/signup/ "Start Free Trial") [Products]() [TinyMCE The world's most trusted WYSIWYG HTML editor, for total control over your rich text editing.](https://www.tiny.cloud/tinymce/) - [Overview](https://www.tiny.cloud/tinymce/) - [Features](https://www.tiny.cloud/tinymce/features/) - [Pricing](https://www.tiny.cloud/pricing/) - [Documentation](https://www.tiny.cloud/docs/tinymce/latest/) - [Demos](https://www.tiny.cloud/docs/tinymce/latest/full-featured-premium-demo/) [MoxieManager Media file management simplified in a PHP or .NET environment.](https://www.tiny.cloud/moxiemanager/) [Drive File and image management directly in the cloud.](https://www.tiny.cloud/drive/) [Start trial](https://www.tiny.cloud/auth/signup/ "Start trial") [Developers]() [Developer CenterExplore frameworks, solutions, and technical guides for building with TinyMCE.](https://www.tiny.cloud/developer-center/) - [Frameworks](https://www.tiny.cloud/developer-center/frameworks/) - [Use Cases](https://www.tiny.cloud/developer-center/use-cases/) [DocumentationIn-depth documentation to help you develop with and customize Tiny products.](https://www.tiny.cloud/docs/tinymce/latest/) - [Getting Started](https://www.tiny.cloud/docs/tinymce/latest/getting-started/) - [Basic Setup](https://www.tiny.cloud/docs/tinymce/latest/basic-setup/) - [API Reference](https://www.tiny.cloud/docs/tinymce/latest/apis/tinymce.root/) - [Migrating to TinyMCE](https://www.tiny.cloud/migrate-to-tinymce/) - [Download TinyMCE Free](https://www.tiny.cloud/get-tiny/) [Support](https://www.tiny.cloud/docs/tinymce/latest/support/) - [License Keys](https://www.tiny.cloud/docs/tinymce/latest/license-key/) - [Editor Loads](https://www.tiny.cloud/docs/tinymce/latest/understanding-editor-loads/) - [Submit a Support Request](https://support.tiny.cloud/hc/en-us/) [Start trial](https://www.tiny.cloud/auth/signup/ "Start trial") [Solutions]() [Use CasesOut-of-the-box editor with infinite use cases and complete design flexibility.](https://www.tiny.cloud/solutions/) - [Content Management System](https://www.tiny.cloud/solutions/cms-editor/) - [Email and Messaging Platform](https://www.tiny.cloud/solutions/wysiwyg-email-editor/) - [Document Management System](https://www.tiny.cloud/solutions/dms-editor/) - [Customer Relationship Management](https://www.tiny.cloud/solutions/crm-editor/) - [Learning Management System](https://www.tiny.cloud/solutions/lms-editor/) - [Internal & SaaS Applications](https://www.tiny.cloud/solutions/saas-applications-editor/) - [Workflow & Collaboration](https://www.tiny.cloud/solutions/workflow-management-editor/) [Roles](https://www.tiny.cloud/html-text-editor-for-developers/) - [Developer](https://www.tiny.cloud/html-text-editor-for-developers/) - [Product Manager](https://www.tiny.cloud/html-text-editor-for-product-managers/) - [Senior Manager](https://www.tiny.cloud/html-text-editor-for-scaling-and-monetizing/) [Security](https://www.tiny.cloud/tinymce/security/)[Hosting](https://www.tiny.cloud/solutions/on-premise-or-cloud-based-text-editor/)[Customization](https://www.tiny.cloud/solutions/customize-text-editor/)[Frameworks & Integrations](https://www.tiny.cloud/solutions/editor-framework-integration/) [Start trial](https://www.tiny.cloud/auth/signup/ "Start trial") [Resources]() [BlogRead the world's best blog on WYSIWYG HTML editors, rich text editing, and insights on building SaaS application editors.](https://www.tiny.cloud/blog/) [White Papers and ReportsSee how Tiny improves ROI, grows revenue and saves development costs.](https://www.tiny.cloud/resources/) [Events & WebinarsExplore upcoming and on-demand events and webinars to unlock the full potential of TinyMCE.](https://www.tiny.cloud/events-and-webinars/) [Case StudiesDiscover why industry leaders and scaling start-ups love, use and trust Tiny products.](https://www.tiny.cloud/customer-stories/) Read: - [Buy vs Build: The Great Debate White Paper](https://www.tiny.cloud/buy-vs-build-whitepaper/) - [Opportunity Cost of Technical Debt](https://www.tiny.cloud/technical-debt-whitepaper/) - [The State of Rich Text Editors 2025 Report](https://www.tiny.cloud/developer-survey-results/) [Start trial](https://www.tiny.cloud/auth/signup/ "Start trial") [Pricing](https://www.tiny.cloud/pricing/) [Contact Us](https://www.tiny.cloud/contact/) [Log In](https://www.tiny.cloud/auth/login/)[Start Free Trial](https://www.tiny.cloud/auth/signup/ "Start Free Trial") *** [Content Marketing & Design](https://www.tiny.cloud/blog/category/design-and-ux/)[Developer Insights](https://www.tiny.cloud/blog/category/engineering/)[How-to Use TinyMCE](https://www.tiny.cloud/blog/category/how-tos-and-tutorials/)[Open Source](https://www.tiny.cloud/blog/category/open-source/)[Product-Led Growth](https://www.tiny.cloud/blog/category/product-management/)[The Tiny Way](https://www.tiny.cloud/blog/category/tiny-sparks/)[World of WYSIWYG](https://www.tiny.cloud/blog/category/wysiwyg-world/) # How to save TinyMCE content to a database June 20th, 2023 5 min read ![](data:image/jpeg;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAALCAMAAABI111xAAAAwFBMVEXZx//ax//cy//Xx//ayP/byP/d0Pvm5evd0fvOxfTPvuPQteTSwvPVxP3QwvzbzP/n3/Dgz/XdyvLgy9DLuOfKuuy3tPKjrvDVw//ZyP/hzPDw0bXrxp332LDnz9/VwvfSyfDWzfPX0vnc1frczP7Yx//x1s792przzY7y1cTby//V1N3k5t77/Prw9/Th1/vZxv/r0dTr0dDo0Njnztrbyv/ZzOXf2+vw6/zr6Prf0f3Zx/7Yxv/Xxv/Zx/3Yxf+hPfr8AAAAV0lEQVQI12NgwAcYkdgsEIrpHxNIlPHPf5gCFgYmRij4xPgfLsgNE2R8yfwHKijKiAB3YCoVQbzrWhDRCxCL/oC1q0LM+AZ3iTWQd4iBwYCf4eMFBlIAAKogD0PCtkl4AAAAAElFTkSuQmCC) ![The PHP element of the database represented by an elephant celebrating with TinyMCE](https://images.ctfassets.net/s600jj41gsex/eihtTelYKrOnMQs1CaGQn/2b80f54539e12e93587c6878776cce28/How_to_save_TinyMCE_content_to_a_database.png?w=2560&q=80&fit=scale) ![The PHP element of the database represented by an elephant celebrating with TinyMCE](https://images.ctfassets.net/s600jj41gsex/eihtTelYKrOnMQs1CaGQn/2b80f54539e12e93587c6878776cce28/How_to_save_TinyMCE_content_to_a_database.png?w=2560&q=80&fit=scale) Written by ![Joe Robinson](data:image/jpeg;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAQCAIAAACZeshMAAAABGdBTUEAALGPC/xhBQAACilpQ0NQaWNjAABIiZ2Wd1RT2RaHz703vVCSEIqU0GtoUgJIDb1IkS4qMQkQSsCQACI2RFRwRFGRpggyKOCAo0ORsSKKhQFRsesEGUTUcXAUG5ZJZK0Z37x5782b3x/3fmufvc/dZ+991roAkPyDBcJMWAmADKFYFOHnxYiNi2dgBwEM8AADbADgcLOzQhb4RgKZAnzYjGyZE/gXvboOIPn7KtM/jMEA/5+UuVkiMQBQmIzn8vjZXBkXyTg9V5wlt0/JmLY0Tc4wSs4iWYIyVpNz8ixbfPaZZQ858zKEPBnLc87iZfDk3CfjjTkSvoyRYBkX5wj4uTK+JmODdEmGQMZv5LEZfE42ACiS3C7mc1NkbC1jkigygi3jeQDgSMlf8NIvWMzPE8sPxc7MWi4SJKeIGSZcU4aNkxOL4c/PTeeLxcwwDjeNI+Ix2JkZWRzhcgBmz/xZFHltGbIiO9g4OTgwbS1tvijUf138m5L3dpZ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29tcGFueflXeTcAAAAhdEVYdGljYzpkZXNjcmlwdGlvbgBzUkdCIElFQzYxOTY2LTIuMVet2kcAAAAmdEVYdGljYzptYW51ZmFjdHVyZXIASUVDIGh0dHA6Ly93d3cuaWVjLmNoHH8ATAAAADd0RVh0aWNjOm1vZGVsAElFQyA2MTk2Ni0yLjEgRGVmYXVsdCBSR0IgY29sb3VyIHNwYWNlIC0gc1JHQkRTSKkAAAAASUVORK5CYII=) ![Joe Robinson](https://images.ctfassets.net/s600jj41gsex/2P4AEkP8R7iCxO4eT5voCe/d18aa214c40aa5e1ecff6f6d216c8097/Portrait-TinyTribe-JR100px.png?w=48&q=50&fit=scale) [Joe Robinson](https://www.tiny.cloud/blog/author/joseph-robinson/) Category [How-to Use TinyMCE](https://www.tiny.cloud/blog/category/how-tos-and-tutorials/) Tagged [Configuration](https://www.tiny.cloud/blog/tag/configuration/)[TinyMCE](https://www.tiny.cloud/blog/tag/tinymce/) Databases are all around us, and without them websites and applications wouldn’t work. Since they’re so vital to online applications, why would components included in those applications – components that claim to speed up development – cause more problems and frustration by blocking database connections? For instance, the rich text editor component of an application lives at the center of content creation apps. A valuable rich text editor provides a fast and easy flow of content from the editor to the database without any roadblocks. Speed and efficiency are a part of best practice for database content management. [TinyMCE is an trusted rich text editor](https://www.tiny.cloud/) that allows you to save content to a database without obstacles. It’s just one example of the many ways TinyMCE is easy to implement, and this post shows you how to save TinyMCE content to a database. ## What is database content management? Database content management is the ability to store and serve content from the database, to anywhere it’s needed in an application. When database content management is done effectively, it shows at the very least, the following practices: 1. Allows for storage of a variety of digital content, including images, text, video, and audio files 2. Fast and effective storage and retrieval 3. Follows a standardized naming convention 4. Connects metadata to each item in the database, providing information to identify content 5. Plans for storage that fits the content, such as local storage, or cloud based storage. Plus, there’s [more to consider before testing out a database](https://www.tableau.com/learn/articles/data-management-best-practices) for content management. Once you’re ready, the following sections explain the steps to save TinyMCE content to a database using an SQLite demo. ## How to save TinyMCE content to a database with PHP The first step is getting TinyMCE working. The following demo is based on [the TinyMCE CMS solution](https://www.tiny.cloud/solutions/cms-editor/). There are some prerequisites to know about before running the demo: 1. Experience with HTML and JavaScript 2. Familiarity with PHP, including prepared statements 3. A text editor to adjust file content 4. Access to the command line through bash or another shell ### Getting TinyMCE started 1. In your development environment, create a new directory for the demo, create an *index.html* file in that directory. Also set up two more folders in the new directory, one for scripts, and one for PHP: ``` mkdir demoApp/ cd demoApp/ touch index.html mkdir scripts/ mkdir php/ ``` COPY 1. Change into the *scripts* folder and create a new JavaScript file for the TinyMCE configuration, which is set up in step 5 of this procedure: ``` cd scripts/ touch tinymceConfig.js ``` COPY 1. Change out of the *scripts* folder and then in the main directory, open the *index.html* file. Add the following starter HTML: ``` <!DOCTYPE html> <html lang="en"> <head>  <meta charset="utf-8">  <meta name="viewport" content="width=device-width, initial-scale=1">  <script src="https://code.jquery.com/jquery-3.7.0.js"></script>  <script src="https://cdn.tiny.cloud/1/no-api-key/tinymce/6/tinymce.min.js" referrerpolicy="origin"></script>  <script src="scripts/tinymceConfig.js"></script> </head> <body>  <h1>TinyMCE CMS Starter Config</h1>  <textarea>    <h1>Visiting Norway</h1>     <p><strong><img style="float: right;" src="https://images.pexels.com/photos/1559825/pexels-photo-1559825.jpeg?auto=compress&amp;cs=tinysrgb&amp;dpr=2&amp;h=750&amp;w=1260" alt="Town" width="300" height="375"></strong>Norway, officially the Kingdom of Norway, is a <a href="https://en.wikipedia.org/wiki/Nordic_countries">Nordic country</a> in Northern Europe, the mainland territory of which comprises the western and northernmost portion of the Scandinavian Peninsula.</p>     <p>The remote Arctic island of Jan Mayen and the archipelago of Svalbard also form part of Norway. Bouvet Island, located in the <a href="https://en.wikipedia.org/wiki/Subantarctic">Subantarctic</a>, is a dependency of Norway; it also lays claims to the Antarctic territories of Peter I Island and Queen Maud Land. The capital and largest city in Norway is <a href="https://en.wikipedia.org/wiki/Oslo">Oslo</a>.<strong><br></strong></p>    <p>Listen to Norway's royal anthem on Spotify:</p>     <div style="left: 0px; width: 100%; height: 152px; position: relative; max-width: 650px;" data-ephox-embed-iri="https://open.spotify.com/track/6SPocux2pBpFp3lshAOek1?si=907d52cf2af94efc"><iframe style="top: 0; left: 0; width: 100%; height: 100%; position: absolute; border: 0;" src="https://open.spotify.com/embed/track/6SPocux2pBpFp3lshAOek1?utm_source=oembed" allow="clipboard-write; encrypted-media; fullscreen; picture-in-picture;" allowfullscreen="allowfullscreen"></iframe></div>    <h2>Geography</h2>    <p>Norway has a total area of 385,207 square kilometres (148,729 sq mi) and had a population of 5,425,270 in January 2022. The country shares a long eastern border with Sweden at a length of 1,619 km (1,006 mi). It is bordered by Finland and Russia to the northeast and the Skagerrak strait to the south, on the other side of which are Denmark and the United Kingdom.</p>    <p>Norway has an extensive coastline, facing the North Atlantic Ocean and the Barents Sea. The maritime influence dominates Norway's climate, with mild lowland temperatures on the sea coasts; the interior, while colder, is also significantly milder than areas elsewhere in the world on such northerly latitudes. Even during polar night in the north, temperatures above freezing are commonplace on the coastline. The maritime influence brings high rainfall and snowfall to some areas of the country.</p>    <p><em>Featuring <a href="https://en.wikipedia.org/wiki/Norway">content from Wikipedia</a></em></p>  </textarea> </body> </html> ``` COPY 1. Add a link to TinyMCE through the CDN in the head section of the document, and a link to the TinyMCE configuration file: ```  <script src="https://cdn.tiny.cloud/1/no-api-key/tinymce/6/tinymce.min.js" referrerpolicy="origin"></script>   <script src="scripts/tinymceConfig.js"></script> ``` COPY > **Note:** The CMS demo makes use of several Premium plugins. When you [sign up for a FREE TinyMCE API key](https://www.tiny.cloud/auth/signup/), you get free access to all Premium plugins for 14 days from when you replace the “no-api-key” string with your own TinyMCE API key. Adding the key also removes any domain name related errors appearing in the text area. 1. Change back into the *scripts/tinymceConfig.js* file, open it, and add the following JavaScript content to get TinyMCE started: ``` tinymce.init({ selector: "#editor", plugins: "a11ychecker advcode advlist advtable anchor autocorrect autosave editimage image link linkchecker lists media mediaembed pageembed powerpaste searchreplace table template tinymcespellchecker typography visualblocks wordcount", toolbar: "undo redo | styles | bold italic underline strikethrough | align | table link image media pageembed | bullist numlist outdent indent | spellcheckdialog a11ycheck typography code", height: 540, a11ychecker_level: "aaa", typography_langs: ["en-US"], typography_default_lang: "en-US", advcode_inline: true, content_style: `        body {          font-family: 'Roboto', sans-serif;          color: #222;        }        img {          height: auto;          margin: auto;          padding: 10px;          display: block;        }        img.medium {          max-width: 25%;        }        a {          color: #116B59;        }        .related-content {          padding: 0 10px;          margin: 0 0 15px 15px;          background: #eee;          width: 200px;          float: right;        }      `, }); ``` COPY 1. Save the changes, and then change back into the main directory. Test out the demo by opening the *index.html* file in a browser, or by running a localhost test [with the Python command,](https://ryanblunden.com/create-a-http-server-with-one-command-thanks-to-python-29fcfdcd240e) or [PHP command](https://www.php.net/manual/en/features.commandline.webserver.php): ![The TinyMCE CMS demo working in the browser and ready to be saved to the database](https://images.ctfassets.net/s600jj41gsex/6LO93YvgD4nqcJyVIQfpza/5b0362977008cbb4f567cb7a9e53010f/img-TinyMCE-save-database-0.gif) ### Getting the database connection established 1. Change into the *scripts* folder, and add the following JavaScript to the TinyMCE init script after the *content\_style* option. It uses the TinyMCE setup option to listen for the change event. The change event registers when the editor loses focus, or the writer presses the Enter key. When the event happens, the jQuery gets the rich text editor content, and posts it onward to the database handler file. This content is what saves TinyMCE content to the database: ```    setup: (editor) => {        editor.on('change', (e) => {          $.ajax({            type: 'POST',            url: 'php/save.php',            data: {              editor: tinymce.get('editor').getContent()            },            success: function(data){              $('#editor').val('');              console.log(data)            }          })        })       }, ``` COPY 1. Change back to the main directory, and then change into the *php* folder. Create a new PHP file for handling interactions with the database: ``` touch connect.php ``` COPY 1. Add the following PHP content to the connection file. This receives the editor content, and then saves the TinyMCE content to a database file: ``` <?php $connect=new SQLite3('tinymceContent.db') or die("Could not connect to database, and save TinyMCE content"); $db="CREATE TABLE IF NOT EXISTS `Content`(id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, Content TEXT)"; $connect->exec($db); ?> ``` COPY 1. Save the changes, and then close the *.php* file. 2. Create a second *.php* file to handle the process of inserting and saving TinyMCE content into the database, and then add the following PHP content: ``` touch save.php ... <?php require_once 'connect.php'; $editorContent=$_POST['editor']; $stmt = $connect->prepare("INSERT INTO `Content` (Content) VALUES (:Content)"); $stmt->bindParam(':Content', $editorContent); $stmt->execute(); echo "Save Data"; ?> ``` COPY 1. Save the changes. ### Saving TinyMCE content to the database file with PHP and SQLite 1. In the browser, refresh the demo, and try entering some new content into the TinyMCE text area, and then clicking away from the editor or pressing the Enter key. If the PHP content is working, you’ll see a 200 status code on the command line (if you’re running the demo with a localhost for tests with Python or PHP): ``` [<date and time>] [::1]:60003 [200]: GET / [<date and time>] [::1]:60003 Closing [<date and time>] [::1]:60003 [200]: GET /tinymceConfig.js [<date and time>] [::1]:60003 Closing [<date and time>] [::1]:60003 Accepted [<date and time>] [::1]:60003 [200]: POST /php/save.php [<date and time>] [::1]:60003 Closing ``` COPY The successful command line content (code 200) indicates that the database file has been created in the *php* folder following the steps set in the *connect.php* file. 1. Navigate into the *php* folder, and then open the *tinymceContent.db* database file with the *SQLite* command: ``` sqlite3 tinymceContent.db  ``` COPY 1. Query the database Content table to see the TinyMCE content saved in the database: ``` SELECT * FROM Content; … 1|<h1>Visiting Norway</h1> <p><strong><img style="float: right;" src="https://images.pexels.com/photos/1559825/pexels-photo-1559825.jpeg?auto=compress&amp;cs=tinysrgb&amp;dpr=2&amp;h=750&amp;w=1260" alt="Town" width="300" height="375"></strong>Norway, officially the Kingdom of Norway, is a <a href="https://en.wikipedia.org/wiki/Nordic_countries">Nordic country</a> in Northern Europe, the mainland territory of which comprises the western and northernmost portion of the Scandinavian Peninsula.</p> ... ``` COPY 1. Exit the database using the *.quit* command ## Next steps for saving TinyMCE content in a database You can rapidly get content from the editor, and save TinyMCE content to a database making use of the process explained in the previous sections. In production, the pattern of collecting data with the [TinyMCE Get method,](https://www.tiny.cloud/blog/how-to-get-content-and-set-content-in-tinymce/) and [binding parameters in prepared statements](https://www.w3schools.com/php/php_mysql_prepared_statements.asp) represent consistent patterns you can make use of for your project. For more on getting a CMS ready using TinyMCE, check out [the tutorial on creating a CMS with TinyMCE](https://www.tiny.cloud/blog/tinymce-for-cms/) to rival the major content management providers out there\! [Try TinyMCE with your database, and sign up for your FREE API key today](https://www.tiny.cloud/get-tiny/) [Configuration](https://www.tiny.cloud/blog/tag/configuration/)[TinyMCE](https://www.tiny.cloud/blog/tag/tinymce/) ![Joe Robinson](data:image/jpeg;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAQCAIAAACZeshMAAAABGdBTUEAALGPC/xhBQAACilpQ0NQaWNjAABIiZ2Wd1RT2RaHz703vVCSEIqU0GtoUgJIDb1IkS4qMQkQSsCQACI2RFRwRFGRpggyKOCAo0ORsSKKhQFRsesEGUTUcXAUG5ZJZK0Z37x5782b3x/3fmufvc/dZ+991roAkPyDBcJMWAmADKFYFOHnxYiNi2dgBwEM8AADbADgcLOzQhb4RgKZAnzYjGyZE/gXvboOIPn7KtM/jMEA/5+UuVkiMQBQmIzn8vjZXBkXyTg9V5wlt0/JmLY0Tc4wSs4iWYIyVpNz8ixbfPaZZQ858zKEPBnLc87iZfDk3CfjjTkSvoyRYBkX5wj4uTK+JmODdEmGQMZv5LEZfE42ACiS3C7mc1NkbC1jkigygi3jeQDgSMlf8NIvWMzPE8sPxc7MWi4SJKeIGSZcU4aNkxOL4c/PTeeLxcwwDjeNI+Ix2JkZWRzhcgBmz/xZFHltGbIiO9g4OTgwbS1tvijUf138m5L3dpZehH/uGUQf+MP2V36ZDQCwpmW12fqHbWkVAF3rAVC7/YfNYC8AirK+dQ59cR66fF5SxOIsZyur3NxcSwGfaykv6O/6nw5/Q198z1K+3e/lYXjzkziSdDFDXjduZnqmRMTIzuJw+Qzmn4f4Hwf+dR4WEfwkvogvlEVEy6ZMIEyWtVvIE4gFmUKGQPifmvgPw/6k2bmWidr4EdCWWAKlIRpAfh4AKCoRIAl7ZCvQ730LxkcD+c2L0ZmYnfvPgv59V7hM/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ctfassets.net/s600jj41gsex/2P4AEkP8R7iCxO4eT5voCe/d18aa214c40aa5e1ecff6f6d216c8097/Portrait-TinyTribe-JR100px.png?w=48&q=50&fit=scale) by[Joe Robinson](https://www.tiny.cloud/blog/author/joseph-robinson/) Technical and creative writer, editor, and a TinyMCE advocate. An enthusiast for teamwork, open source software projects, and baking. Can often be found puzzling over obscure history, cryptic words, and lucid writing. ## Related Articles - ![How to Create a Laravel Project with TinyMCE](data:image/jpeg;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAALCAMAAABI111xAAABqlBMVEUJElMKE1QAB08ABk4ABU4ABE4ACE8IElMCDFEAAk4AAU0AB04EDlEJE1QAAU4cIl0tMmkkKmUtMmgrMWgqL2gzOGsyN2s1Om0zOGwhJl8AA04AAEw5O2JlZn0rL1whKGQ8Q3o6QXk+RXo9RHpCSX1BSH08Q3gxOHEdJWMAAE4ABk8tMVxWWHMcIVYjKWVbZZdseKdrdqZrd6Zsd6ZqdaVjbZ5YYpVFTYMsMmtCRW4EDlIAAU8ABU8BDlMAA08jKmRdZ5hveqlueahpdKRhbJ1aZJdBS4Nxcoq6usFJS2wAAFAOFVQEDVEmLGVaZJRpdKJoc6BpdKFkb5xgaplZYpNETIJHS3RzdIohJVgCDVIDDFABCU8iKGQ7Ro0+SpI/SpA/SpFAS5BAS5FDTpM1Pn8jKmkEFF4AAE0JElIAAUoOHGdTZdNwf+RvfuJygONtfOJse+J1guNxgOQuQKQaIFgUG1kLE1IABU0SIXEcKHYVI3QeKXUXJXUfKnYcKXgEFGABCEsFDlAIEFEMFFILFFQAA0sAAEIAADwAADsAAD0AAD8AAUgBCE4CC0/x2NGcAAAAgUlEQVQIHV3BsQ2CUBRA0XvhCcYCYu0EDuJSJjS6hzs4iBs4gIWFpQnIFz9UniOKAjJJqaRP1n4YRSCwH9d9ZdRvy8oJzh7gzkWiMLsTtP6BSFszUuFsiHg8D2a4CCJozXABBcO1ydrZpRmGqKvUvLbqWPrTuVHPp9VRJVE4ubnvvvvOH3NuUin/AAAAAElFTkSuQmCC) ![How to Create a Laravel Project with TinyMCE](https://images.ctfassets.net/s600jj41gsex/5d3MI3yLPU2yRuI7mWlOw3/3c0ecc44fff59f8f90e95ec82267edde/How_to_Create_a_Laravel_Project_with_TinyMCE.png?w=739&q=50&fit=scale) [How-to Use TinyMCE](https://www.tiny.cloud/blog/category/how-tos-and-tutorials/) Feb 26th, 2026 ### [How to Integrate TinyMCE into a Laravel Project](https://www.tiny.cloud/blog/how-to-add-tinymce-to-laravel/) - ![How to Build a Team Collaboration App with TinyMCE + React](data:image/jpeg;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAALCAMAAABI111xAAABtlBMVEUIE1QAB08ACE8ABk8IElQIElMGElQACVEAAE8AAU8AA08ABE8ACVAADlMADlQAClEADFQAEVUHE1UeF04kGk4jGE4ODU8oGE4RDU8OC08AD1QpJFg3KFYAEVYAAVAAE1ZCMFUvJlcADFMAAFBnSkmQZEKLXENxRkh9SUiLTUhwOktGLlZNL1MAAFgACVlVM1M8KFdTOkiAVj6FVT1/TEB2QUOFRUJ2OUZ0Nk2BOk9LIFAABlEAAlhZXHebnKddYXsAA1kAEFUACFAAAEtMQ1x7aGyCbG56X2VzWGSBZnB5XmxaKU11NE9CHE+VlqLZ2dyUlaIAAFEAA1AAAEdaXXZ/gZKIi5qHipp4fI6FiZh0eIsADFEAAE4AAk8ACFMABlUAAFZGSmx8fo89Q2oAFloIF1dQUW2JiZeRkZ6YmaSHiJYLE1EAAEgAAE0ABE4ABFEXI1yEhZRqa4IAAFQADVlZN1E+K1YAAEwDC08wMlw+QGMxM1wvMVsABU8ZJV2IiZhub4QAAFMAElUtIlgeHlgADFIHEVMAB1AAAk4ACVQAE1gADlYABVEBEVQJE1QKE1QAB04JElMYf15lAAAAm0lEQVQIHQXBMS5EUQAF0HteXsbjxxDVZEQh0chX2oHEDuxCNEIyyZRahcJC9JagoVBPJGpiZFB950gkkSQZIkPBCOJ3SDaw3ITWAV8rE4C6C/hYK997rDoW2iEArz3gBIDH6fspPNRtAM4AtWYHANyfs14PwCL7NxdjZMxV3fL5lOOjGZOCv9vrdlla++n70UwyH16e37Lsyt0/AyIgqverEawAAAAASUVORK5CYII=) ![How to Build a Team Collaboration App with TinyMCE + React](https://images.ctfassets.net/s600jj41gsex/5aMx0eNy8VUErE5AO5ZkiQ/c9d7e2d4aea4b8402e3bf3b2893ce162/How_to_Build_a_Team_Collaboration_App_with_TinyMCE___React.png?w=739&q=50&fit=scale) [How-to Use TinyMCE](https://www.tiny.cloud/blog/category/how-tos-and-tutorials/) Feb 18th, 2026 ### [How to Build a Team Collaboration App with TinyMCE and React](https://www.tiny.cloud/blog/how-to-build-React-team-collaboration-app/) - ![How to Build a Help Desk App in React with TinyMCE](data:image/jpeg;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAALCAMAAABI111xAAABsFBMVEUKE1QACE8AB08ABk4KElMJElMEDVEABU4ABk8ABU8ACVADDVMAClEACVEDCVIHD1QJElQAAU4AAEwAAEoAAEsAAEkAAE4EDFMTKFwQLl4ED1UAAVAFElURN2MSLF4BCFI2N15NTWpBQWNERGVRUW1SUm0yO2AANF4AO2EAIVUEBVITN2MLQWgAAFcAAE8AB1gKQ2kRM2ECCFIAAEdYW3SIiph8fY17fI2JiZeNjZpXboMAXHgAbYQARmgBAE4EEVUABVhZXHebnKdeYXsDD1QAB1AAAEgAQWYAYn0AXnoAX3oAUnEAZn8AXHcAFVKVlqLZ2dyUlaIAAFAAAlBPU26Fiph0eIp6f4+Ah5aNkJ1+gpEgM1wAGlMECFEOEVUJClUAClhIS2x8fo8+Q2kAE1oIFlY6O2BeXnZKSmhPTmtkY3leXXVUVG8ODE8AAE0KD1UONWQEY4cJNGQAAlcAEVkLOmMSL18DDFMKDVUIUHcAjK8IT3cIClUAA1AGElURJlsRIVoBClIABE4JElUTI1oPPWoJEVQBCVABC1IGEFQLFFQFCVIFAVIFCFIAB04LE1QrHffIAAAAnElEQVQIHWXBMQ7BYBiA4e9tv0p+pSKV2AiLSzgAk8TqEI5gEqPF5h5NLNLR4gx2i6TageRvNWmaCM+DCFJDpKCk0gBBircUBiHzKXWBwsnJRamp2+KPDvlx76MhPAOwChcvHEGHSKVNQGVGRekt+XYbU+ri5s4gvK6Oa2rOI03SZDHNDi/f901za4zZu7I7WRvHVnAn6m3sea7RB77EJUgK3FzNAAAAAElFTkSuQmCC) ![How to Build a Help Desk App in React with TinyMCE](https://images.ctfassets.net/s600jj41gsex/4EDRrkGzEoAesCGWovUmwu/d2955fa54b279c00374849c8e3735f51/How_to_Build_a_Help_Desk_App_in_React_with_TinyMCE.png?w=739&q=50&fit=scale) [How-to Use TinyMCE](https://www.tiny.cloud/blog/category/how-tos-and-tutorials/) Feb 11th, 2026 ### [How to Build a Help Desk App in React with TinyMCE](https://www.tiny.cloud/blog/build-help-desk-app-with-react/) Join 100,000+ developers who get regular tips & updates from the Tiny team. This site is protected by reCAPTCHA and the Google [Privacy Policy](https://policies.google.com/privacy) and [Terms of Service](https://policies.google.com/terms) apply. Stay connected [![SOC2 compliance badge](https://www.tiny.cloud/images/footer/SOC2-compliance.png)](https://www.tiny.cloud/tinymce/security) ### Products - [TinyMCE](https://www.tiny.cloud/tinymce) - [Drive](https://www.tiny.cloud/drive) - [MoxieManager](https://www.tiny.cloud/moxiemanager) ### Pricing - [TinyMCE](https://www.tiny.cloud/pricing) - [Drive](https://www.tiny.cloud/pricing/drive) - [MoxieManager](https://www.tiny.cloud/pricing/moxiemanager) ### Developers - [Documentation](https://www.tiny.cloud/docs/tinymce/latest) - [Get Started](https://www.tiny.cloud/docs/tinymce/latest/cloud-quick-start) - [Integrations](https://www.tiny.cloud/developer-center/editor-framework-integration) - [API Reference](https://www.tiny.cloud/docs/tinymce/latest/apis/tinymce.root) - [Roadmap](https://www.tiny.cloud/roadmap) - [Support](https://www.tiny.cloud/docs/tinymce/latest/support) - [Blog](https://www.tiny.cloud/blog) - [Get TinyMCE Free](https://www.tiny.cloud/get-tiny) ### Company - [About](https://www.tiny.cloud/about) - [Customer Stories](https://www.tiny.cloud/customer-stories) - [Careers](https://tiugotech.recruitee.com/) - [Partners](https://www.tiny.cloud/partner-directory) - [News](https://www.tiny.cloud/news) - [Contact Us](https://www.tiny.cloud/contact) - [Legal](https://www.tiny.cloud/legal) - [Security](https://www.tiny.cloud/tinymce/security) - [Trust Center](https://www.tiny.cloud/trust-center) - [Status Page](https://status.tiny.cloud/) © Copyright 2026 Tiny Technologies Inc. TinyMCE® and Tiny® are registered trademarks of Tiny Technologies, Inc.
Readable Markdown
Databases are all around us, and without them websites and applications wouldn’t work. Since they’re so vital to online applications, why would components included in those applications – components that claim to speed up development – cause more problems and frustration by blocking database connections? For instance, the rich text editor component of an application lives at the center of content creation apps. A valuable rich text editor provides a fast and easy flow of content from the editor to the database without any roadblocks. Speed and efficiency are a part of best practice for database content management. [TinyMCE is an trusted rich text editor](https://www.tiny.cloud/) that allows you to save content to a database without obstacles. It’s just one example of the many ways TinyMCE is easy to implement, and this post shows you how to save TinyMCE content to a database. ## What is database content management? Database content management is the ability to store and serve content from the database, to anywhere it’s needed in an application. When database content management is done effectively, it shows at the very least, the following practices: 1. Allows for storage of a variety of digital content, including images, text, video, and audio files 2. Fast and effective storage and retrieval 3. Follows a standardized naming convention 4. Connects metadata to each item in the database, providing information to identify content 5. Plans for storage that fits the content, such as local storage, or cloud based storage. Plus, there’s [more to consider before testing out a database](https://www.tableau.com/learn/articles/data-management-best-practices) for content management. Once you’re ready, the following sections explain the steps to save TinyMCE content to a database using an SQLite demo. ## How to save TinyMCE content to a database with PHP The first step is getting TinyMCE working. The following demo is based on [the TinyMCE CMS solution](https://www.tiny.cloud/solutions/cms-editor/). There are some prerequisites to know about before running the demo: 1. Experience with HTML and JavaScript 2. Familiarity with PHP, including prepared statements 3. A text editor to adjust file content 4. Access to the command line through bash or another shell ### Getting TinyMCE started 1. In your development environment, create a new directory for the demo, create an *index.html* file in that directory. Also set up two more folders in the new directory, one for scripts, and one for PHP: ``` mkdir demoApp/ cd demoApp/ touch index.html mkdir scripts/ mkdir php/ ``` 1. Change into the *scripts* folder and create a new JavaScript file for the TinyMCE configuration, which is set up in step 5 of this procedure: ``` cd scripts/ touch tinymceConfig.js ``` 1. Change out of the *scripts* folder and then in the main directory, open the *index.html* file. Add the following starter HTML: ``` <!DOCTYPE html> <html lang="en"> <head>  <meta charset="utf-8">  <meta name="viewport" content="width=device-width, initial-scale=1">  <script src="https://code.jquery.com/jquery-3.7.0.js"></script>  <script src="https://cdn.tiny.cloud/1/no-api-key/tinymce/6/tinymce.min.js" referrerpolicy="origin"></script>  <script src="scripts/tinymceConfig.js"></script> </head> <body>  <h1>TinyMCE CMS Starter Config</h1>  <textarea>    <h1>Visiting Norway</h1>     <p><strong><img style="float: right;" src="https://images.pexels.com/photos/1559825/pexels-photo-1559825.jpeg?auto=compress&amp;cs=tinysrgb&amp;dpr=2&amp;h=750&amp;w=1260" alt="Town" width="300" height="375"></strong>Norway, officially the Kingdom of Norway, is a <a href="https://en.wikipedia.org/wiki/Nordic_countries">Nordic country</a> in Northern Europe, the mainland territory of which comprises the western and northernmost portion of the Scandinavian Peninsula.</p>     <p>The remote Arctic island of Jan Mayen and the archipelago of Svalbard also form part of Norway. Bouvet Island, located in the <a href="https://en.wikipedia.org/wiki/Subantarctic">Subantarctic</a>, is a dependency of Norway; it also lays claims to the Antarctic territories of Peter I Island and Queen Maud Land. The capital and largest city in Norway is <a href="https://en.wikipedia.org/wiki/Oslo">Oslo</a>.<strong><br></strong></p>    <p>Listen to Norway's royal anthem on Spotify:</p>     <div style="left: 0px; width: 100%; height: 152px; position: relative; max-width: 650px;" data-ephox-embed-iri="https://open.spotify.com/track/6SPocux2pBpFp3lshAOek1?si=907d52cf2af94efc"><iframe style="top: 0; left: 0; width: 100%; height: 100%; position: absolute; border: 0;" src="https://open.spotify.com/embed/track/6SPocux2pBpFp3lshAOek1?utm_source=oembed" allow="clipboard-write; encrypted-media; fullscreen; picture-in-picture;" allowfullscreen="allowfullscreen"></iframe></div>    <h2>Geography</h2>    <p>Norway has a total area of 385,207 square kilometres (148,729 sq mi) and had a population of 5,425,270 in January 2022. The country shares a long eastern border with Sweden at a length of 1,619 km (1,006 mi). It is bordered by Finland and Russia to the northeast and the Skagerrak strait to the south, on the other side of which are Denmark and the United Kingdom.</p>    <p>Norway has an extensive coastline, facing the North Atlantic Ocean and the Barents Sea. The maritime influence dominates Norway's climate, with mild lowland temperatures on the sea coasts; the interior, while colder, is also significantly milder than areas elsewhere in the world on such northerly latitudes. Even during polar night in the north, temperatures above freezing are commonplace on the coastline. The maritime influence brings high rainfall and snowfall to some areas of the country.</p>    <p><em>Featuring <a href="https://en.wikipedia.org/wiki/Norway">content from Wikipedia</a></em></p>  </textarea> </body> </html> ``` 1. Add a link to TinyMCE through the CDN in the head section of the document, and a link to the TinyMCE configuration file: ```  <script src="https://cdn.tiny.cloud/1/no-api-key/tinymce/6/tinymce.min.js" referrerpolicy="origin"></script>   <script src="scripts/tinymceConfig.js"></script> ``` > **Note:** The CMS demo makes use of several Premium plugins. When you [sign up for a FREE TinyMCE API key](https://www.tiny.cloud/auth/signup/), you get free access to all Premium plugins for 14 days from when you replace the “no-api-key” string with your own TinyMCE API key. Adding the key also removes any domain name related errors appearing in the text area. 1. Change back into the *scripts/tinymceConfig.js* file, open it, and add the following JavaScript content to get TinyMCE started: ``` tinymce.init({ selector: "#editor", plugins: "a11ychecker advcode advlist advtable anchor autocorrect autosave editimage image link linkchecker lists media mediaembed pageembed powerpaste searchreplace table template tinymcespellchecker typography visualblocks wordcount", toolbar: "undo redo | styles | bold italic underline strikethrough | align | table link image media pageembed | bullist numlist outdent indent | spellcheckdialog a11ycheck typography code", height: 540, a11ychecker_level: "aaa", typography_langs: ["en-US"], typography_default_lang: "en-US", advcode_inline: true, content_style: `        body {          font-family: 'Roboto', sans-serif;          color: #222;        }        img {          height: auto;          margin: auto;          padding: 10px;          display: block;        }        img.medium {          max-width: 25%;        }        a {          color: #116B59;        }        .related-content {          padding: 0 10px;          margin: 0 0 15px 15px;          background: #eee;          width: 200px;          float: right;        }      `, }); ``` 1. Save the changes, and then change back into the main directory. Test out the demo by opening the *index.html* file in a browser, or by running a localhost test [with the Python command,](https://ryanblunden.com/create-a-http-server-with-one-command-thanks-to-python-29fcfdcd240e) or [PHP command](https://www.php.net/manual/en/features.commandline.webserver.php): ![The TinyMCE CMS demo working in the browser and ready to be saved to the database](https://images.ctfassets.net/s600jj41gsex/6LO93YvgD4nqcJyVIQfpza/5b0362977008cbb4f567cb7a9e53010f/img-TinyMCE-save-database-0.gif) ### Getting the database connection established 1. Change into the *scripts* folder, and add the following JavaScript to the TinyMCE init script after the *content\_style* option. It uses the TinyMCE setup option to listen for the change event. The change event registers when the editor loses focus, or the writer presses the Enter key. When the event happens, the jQuery gets the rich text editor content, and posts it onward to the database handler file. This content is what saves TinyMCE content to the database: ```    setup: (editor) => {        editor.on('change', (e) => {          $.ajax({            type: 'POST',            url: 'php/save.php',            data: {              editor: tinymce.get('editor').getContent()            },            success: function(data){              $('#editor').val('');              console.log(data)            }          })        })       }, ``` 1. Change back to the main directory, and then change into the *php* folder. Create a new PHP file for handling interactions with the database: ``` touch connect.php ``` 1. Add the following PHP content to the connection file. This receives the editor content, and then saves the TinyMCE content to a database file: ``` <?php $connect=new SQLite3('tinymceContent.db') or die("Could not connect to database, and save TinyMCE content"); $db="CREATE TABLE IF NOT EXISTS `Content`(id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, Content TEXT)"; $connect->exec($db); ?> ``` 1. Save the changes, and then close the *.php* file. 2. Create a second *.php* file to handle the process of inserting and saving TinyMCE content into the database, and then add the following PHP content: ``` touch save.php ... <?php require_once 'connect.php'; $editorContent=$_POST['editor']; $stmt = $connect->prepare("INSERT INTO `Content` (Content) VALUES (:Content)"); $stmt->bindParam(':Content', $editorContent); $stmt->execute(); echo "Save Data"; ?> ``` 1. Save the changes. ### Saving TinyMCE content to the database file with PHP and SQLite 1. In the browser, refresh the demo, and try entering some new content into the TinyMCE text area, and then clicking away from the editor or pressing the Enter key. If the PHP content is working, you’ll see a 200 status code on the command line (if you’re running the demo with a localhost for tests with Python or PHP): ``` [<date and time>] [::1]:60003 [200]: GET / [<date and time>] [::1]:60003 Closing [<date and time>] [::1]:60003 [200]: GET /tinymceConfig.js [<date and time>] [::1]:60003 Closing [<date and time>] [::1]:60003 Accepted [<date and time>] [::1]:60003 [200]: POST /php/save.php [<date and time>] [::1]:60003 Closing ``` The successful command line content (code 200) indicates that the database file has been created in the *php* folder following the steps set in the *connect.php* file. 1. Navigate into the *php* folder, and then open the *tinymceContent.db* database file with the *SQLite* command: ``` sqlite3 tinymceContent.db  ``` 1. Query the database Content table to see the TinyMCE content saved in the database: ``` SELECT * FROM Content; … 1|<h1>Visiting Norway</h1> <p><strong><img style="float: right;" src="https://images.pexels.com/photos/1559825/pexels-photo-1559825.jpeg?auto=compress&amp;cs=tinysrgb&amp;dpr=2&amp;h=750&amp;w=1260" alt="Town" width="300" height="375"></strong>Norway, officially the Kingdom of Norway, is a <a href="https://en.wikipedia.org/wiki/Nordic_countries">Nordic country</a> in Northern Europe, the mainland territory of which comprises the western and northernmost portion of the Scandinavian Peninsula.</p> ... ``` 1. Exit the database using the *.quit* command ## Next steps for saving TinyMCE content in a database You can rapidly get content from the editor, and save TinyMCE content to a database making use of the process explained in the previous sections. In production, the pattern of collecting data with the [TinyMCE Get method,](https://www.tiny.cloud/blog/how-to-get-content-and-set-content-in-tinymce/) and [binding parameters in prepared statements](https://www.w3schools.com/php/php_mysql_prepared_statements.asp) represent consistent patterns you can make use of for your project. For more on getting a CMS ready using TinyMCE, check out [the tutorial on creating a CMS with TinyMCE](https://www.tiny.cloud/blog/tinymce-for-cms/) to rival the major content management providers out there\!
Shard19 (laksa)
Root Hash15564724552215073219
Unparsed URLcloud,tiny!www,/blog/save-content-database/ s443