How can I submit html data to MySQL using onsubmit</a></h1> </div> <div class="grid fw-wrap pb8 mb16 bb bc-black-075"> <div class="grid--cell ws-nowrap mr16 mb8" title="2016-01-12 19:07:53Z"> <span class="fc-light mr2">Asked</span> <time itemprop="dateCreated" datetime="2014-01-14T20:31:47.500" class="fromnow">Jan 14 '14 at 20:31</time> </div> <div class="grid--cell ws-nowrap mr16 mb8"> <span class="fc-light mr2">Active</span> <time class="fromnow" title="2014-01-14T21:13:40.640" datetime="2014-01-14T21:13:40.640">Jan 14 '14 at 21:13</a> </div> <div class="grid--cell ws-nowrap mb8" title="Viewed 229 times"> <span class="fc-light mr2">Viewed</span> 229 times </div> </div> <div id="mainbar" role="main" aria-label="questions and answers"> <div id="question" class="question" data-questionid="21123403" data-ownerid="3195559" data-score="0"> <div class="post-layout"> <div class="votecell post-layout--left"> <div class="js-voting-container grid jc-center fd-column ai-stretch gs4 fc-black-200" data-post-id="21123403"> <button class="js-vote-up-btn grid--cell s-btn s-btn__unset c-pointer"><svg aria-hidden="true" class="m0 svg-icon iconArrowUpLg" width="36" height="36" viewBox="0 0 36 36"><path d="M2 26h32L18 10 2 26z"></path></svg></button> <div class="js-vote-count grid--cell fc-black-500 fs-title grid fd-column ai-center" itemprop="upvoteCount" data-value="0">0</div> <button class="js-bookmark-btn s-btn s-btn__unset c-pointer py4"> <svg aria-hidden="true" class="svg-icon iconBookmark" width="18" height="18" viewBox="0 0 18 18"><path d="M6 1a2 2 0 00-2 2v14l5-4 5 4V3a2 2 0 00-2-2H6zm3.9 3.83h2.9l-2.35 1.7.9 2.77L9 7.59l-2.35 1.7.9-2.76-2.35-1.7h2.9L9 2.06l.9 2.77z"></path></svg> <div class="js-bookmark-count mt4" data-value=""></div> </button> </div> </div> <div class="postcell post-layout--right"> <div class="s-prose js-post-body" itemprop="text"><p>I'm using the HTML tag to display html/js code retrieved from my mysql db. </p> <p>The user can edit this code (xmp contentEditable='true') and save it back to the mysql db.</p> <p>I'm able to retrieve the data (html/js code) from mysql and display it between xmp tags (I have this in a form), but once I submit it, it doesn't get passed to the other php page.</p> <p>This is my form, with the xmp tag populated using php (mysql data):</p> <pre><code>&lt;form action="save-script.php" method="POST" onsubmit="document.getElementById('hidden_data').value = document.getElementById('html_output').innerHTML;"&gt; &lt;?php echo "&lt;xmp id='html_output' contentEditable='false'&gt;" . $formcodelong. "&lt;/xmp&gt;"; echo "&lt;input name='formid' type='hidden' value='" . $formid. "'/&gt;"; ?&gt; &lt;input id="hidden_data" name="data" type="hidden"/&gt; &lt;input type="submit" Value="Enter" id="submitthis"&gt; &lt;/form&gt; </code></pre> <p>This (save-script.php) is where i'm trying to read what's been posted</p> <pre><code>// Get form values $data = $_POST['data']; echo "&lt;br /&gt;data : " . $data ; </code></pre> <p>I was hoping to do the same thing I read here, except with xmp instead of div: <a href="../../questions/19287859/how-can-i-submit-div-data-to-mysql">How can I submit div data to MySQL</a></p></div> <div class="mt24 mb12"> <div class="post-taglist grid gs4 gsy fd-column"> <div class="grid ps-relative"> <a href="../../questions/tagged/php" class="post-tag js-gps-track" title="show questions tagged 'php'" rel="tag">php</a> <a href="../../questions/tagged/html" class="post-tag js-gps-track" title="show questions tagged 'html'" rel="tag">html</a> <a href="../../questions/tagged/submit" class="post-tag js-gps-track" title="show questions tagged 'submit'" rel="tag">submit</a> <a href="../../questions/tagged/xmp" class="post-tag js-gps-track" title="show questions tagged 'xmp'" rel="tag">xmp</a> </div> </div> </div> <div class="mb0"> <div class="mt16 grid gs8 gsy fw-wrap jc-end ai-start pt4 mb16"> <div class="grid--cell mr16 fl1 w96"></div> <div class="post-signature grid--cell"> <div class="s-user-card s-user-card"> <time class="s-user-card--time" datetime="edited May 23 '17 at 11:57">edited May 23 '17 at 11:57</time> <a href="../../users/-1/community" class="s-avatar s-avatar__32 s-user-card--avatar"> <img class="s-avatar--image" src="../../users/profiles/-1.webp" data-jdenticon-width="32" data-jdenticon-height="32" data-jdenticon-value="Community" /> </a> <div class="s-user-card--info"> <a href="../../users/-1/community" class="s-user-card--link">Community</a> <ul class="s-user-card--awards"> <li class="s-user-card--rep" title="reputation score">1</li> <li class="s-award-bling s-award-bling__silver" title="1 silver badges">1</li> </ul> </div> </div> </div> <div class="post-signature owner grid--cell"> <div class="s-user-card s-user-card"> <time class="s-user-card--time" datetime="asked Jan 14 '14 at 20:31">asked Jan 14 '14 at 20:31</time> <a href="../../users/3195559/user3195559" class="s-avatar s-avatar__32 s-user-card--avatar"> <img class="s-avatar--image" src="../../users/profiles/3195559.webp" data-jdenticon-width="32" data-jdenticon-height="32" data-jdenticon-value="user3195559" /> </a> <div class="s-user-card--info"> <a href="../../users/3195559/user3195559" class="s-user-card--link">user3195559</a> <ul class="s-user-card--awards"> <li class="s-user-card--rep" title="reputation score">13</li> <li class="s-award-bling s-award-bling__bronze" title="4 bronze badges">4</li> </ul> </div> </div> </div> </div> </div> </div> <div class="post-layout--right js-post-comments-component"> <div id="comments-21123403" class="comments js-comments-container bt bc-black-075 mt12 " data-post-id="21123403" data-min-length="15"> <ul class="comments-list js-comments-list" data-remaining-comments-count="0" data-canpost="false" data-cansee="true" data-comments-unavailable="false" data-addlink-disabled="true"> <li id="comment-31785029" class="comment js-comment " data-comment-id="31785029" data-comment-owner-id="1796105" data-comment-score="0"> <div class="js-comment-actions comment-actions"> <div class="comment-score js-comment-edit-hide"> </div> </div> <div class="comment-text js-comment-text-and-form"> <a name="comment31785029_21123403"></a> <div class="comment-body js-comment-edit-hide"> <span class="comment-copy">What is the output of your latest code above?</span> –&nbsp;<a href="../../users/1796105/huseyin-babal" title="15,400 reputation" class="comment-user ">Hüseyin BABAL</a> <span class="comment-date" dir="ltr"><a class="comment-link" href="../../questions/21123403/how-can-i-submit-html-xmp-data-to-mysql-using-onsubmit#comment31785029_21123403"><span title="2014-01-14T20:38:19.763 License: CC BY-SA 3.0" class="relativetime-clean">Jan 14 '14 at 20:38</span></a></span> </div> </div> </li> <li id="comment-31785162" class="comment js-comment " data-comment-id="31785162" data-comment-owner-id="3195559" data-comment-score="0"> <div class="js-comment-actions comment-actions"> <div class="comment-score js-comment-edit-hide"> </div> </div> <div class="comment-text js-comment-text-and-form"> <a name="comment31785162_21123403"></a> <div class="comment-body js-comment-edit-hide"> <span class="comment-copy">if you're talking about echo $data in save-script.php, it does not display anything.</span> –&nbsp;<a href="../../users/3195559/user3195559" title="13 reputation" class="comment-user owner">user3195559</a> <span class="comment-date" dir="ltr"><a class="comment-link" href="../../questions/21123403/how-can-i-submit-html-xmp-data-to-mysql-using-onsubmit#comment31785162_21123403"><span title="2014-01-14T20:42:04.137 License: CC BY-SA 3.0" class="relativetime-clean">Jan 14 '14 at 20:42</span></a></span> </div> </div> </li> <li id="comment-31785324" class="comment js-comment " data-comment-id="31785324" data-comment-owner-id="1796105" data-comment-score="0"> <div class="js-comment-actions comment-actions"> <div class="comment-score js-comment-edit-hide"> </div> </div> <div class="comment-text js-comment-text-and-form"> <a name="comment31785324_21123403"></a> <div class="comment-body js-comment-edit-hide"> <span class="comment-copy">Could you please look at your rendered html form by using firebug? I think there is something about your generated form html</span> –&nbsp;<a href="../../users/1796105/huseyin-babal" title="15,400 reputation" class="comment-user ">Hüseyin BABAL</a> <span class="comment-date" dir="ltr"><a class="comment-link" href="../../questions/21123403/how-can-i-submit-html-xmp-data-to-mysql-using-onsubmit#comment31785324_21123403"><span title="2014-01-14T20:46:25.797 License: CC BY-SA 3.0" class="relativetime-clean">Jan 14 '14 at 20:46</span></a></span> </div> </div> </li> <li id="comment-31786018" class="comment js-comment " data-comment-id="31786018" data-comment-owner-id="3195559" data-comment-score="0"> <div class="js-comment-actions comment-actions"> <div class="comment-score js-comment-edit-hide"> </div> </div> <div class="comment-text js-comment-text-and-form"> <a name="comment31786018_21123403"></a> <div class="comment-body js-comment-edit-hide"> <span class="comment-copy">Thanks cubuzoa. I downloaded firebug, and saw that there was a special (unwanted) character in there : document.getElementById('html_output'). It wasn't visible in the code editor. I changed the charset from ISO-8859-1 to UTF-8 in my html page, and retyped that line of code. It worked. Thanks!</span> –&nbsp;<a href="../../users/3195559/user3195559" title="13 reputation" class="comment-user owner">user3195559</a> <span class="comment-date" dir="ltr"><a class="comment-link" href="../../questions/21123403/how-can-i-submit-html-xmp-data-to-mysql-using-onsubmit#comment31786018_21123403"><span title="2014-01-14T21:04:11.673 License: CC BY-SA 3.0" class="relativetime-clean">Jan 14 '14 at 21:04</span></a></span> </div> </div> </li> <li id="comment-31786381" class="comment js-comment " data-comment-id="31786381" data-comment-owner-id="1796105" data-comment-score="0"> <div class="js-comment-actions comment-actions"> <div class="comment-score js-comment-edit-hide"> </div> </div> <div class="comment-text js-comment-text-and-form"> <a name="comment31786381_21123403"></a> <div class="comment-body js-comment-edit-hide"> <span class="comment-copy">Good to hear that, I answered your question</span> –&nbsp;<a href="../../users/1796105/huseyin-babal" title="15,400 reputation" class="comment-user ">Hüseyin BABAL</a> <span class="comment-date" dir="ltr"><a class="comment-link" href="../../questions/21123403/how-can-i-submit-html-xmp-data-to-mysql-using-onsubmit#comment31786381_21123403"><span title="2014-01-14T21:14:17.800 License: CC BY-SA 3.0" class="relativetime-clean">Jan 14 '14 at 21:14</span></a></span> </div> </div> </li> </ul> </div> </div> </div> </div> <div id="answers"> <a name="tab-top"></a> <div id="answers-header"> <div class="answers-subheader grid ai-center mb8"> <div class="grid--cell fl1"> <h2 class="mb0" data-answercount="9">1 Answers<span style="display:none;" itemprop="answerCount">1</span></h2> </div> </div> </div> <a name="21124159"></a> <div id="answer-21124159" class="answer accepted-answer" data-answerid="21124159" data-ownerid="1796105" data-score="-1" itemprop="acceptedAnswer" itemscope="" itemtype="https://schema.org/Answer"> <div class="post-layout"> <div class="votecell post-layout--left"> <div class="js-voting-container grid jc-center fd-column ai-stretch gs4 fc-black-200" data-post-id="21124159"> <button class="js-vote-up-btn grid--cell s-btn s-btn__unset c-pointer"><svg aria-hidden="true" class="m0 svg-icon iconArrowUpLg" width="36" height="36" viewBox="0 0 36 36"><path d="M2 26h32L18 10 2 26z"></path></svg></button> <div class="js-vote-count grid--cell fc-black-500 fs-title grid fd-column ai-center" itemprop="upvoteCount" data-value="-1">-1</div> <div class="js-accepted-answer-indicator grid--cell fc-green-500 py6 mtn8"><div class="ta-center"><svg aria-hidden="true" class="svg-icon iconCheckmarkLg" width="36" height="36" viewBox="0 0 36 36"><path d="m6 14 8 8L30 6v8L14 30l-8-8v-8z"></path></svg></div></div> </div> </div> <div class="postcell post-layout--right"> <div class="s-prose js-post-body" itemprop="text"><p>There is nothing wrong on PHP side. Could you please look at your rendered html form by using firebug? I think there is something about your generated form html. If any errors, fix them and it should work</p></div> <div class="mb0"> <div class="mt16 grid gs8 gsy fw-wrap jc-end ai-start pt4 mb16"> <div class="grid--cell mr16 fl1 w96"></div> <div class="post-signature grid--cell"> <div class="s-user-card s-user-card"> <time class="s-user-card--time" datetime="answered Jan 14 '14 at 21:13">answered Jan 14 '14 at 21:13</time> <a href="../../users/1796105/huseyin-babal" class="s-avatar s-avatar__32 s-user-card--avatar"> <img class="s-avatar--image" src="../../users/profiles/1796105.webp" data-jdenticon-width="32" data-jdenticon-height="32" data-jdenticon-value="Hüseyin BABAL" /> </a> <div class="s-user-card--info"> <a href="../../users/1796105/huseyin-babal" class="s-user-card--link">Hüseyin BABAL</a> <ul class="s-user-card--awards"> <li class="s-user-card--rep" title="reputation score">15,400</li> <li class="s-award-bling s-award-bling__gold" title="4 gold badges">4</li> <li class="s-award-bling s-award-bling__silver" title="51 silver badges">51</li> <li class="s-award-bling s-award-bling__bronze" title="73 bronze badges">73</li> </ul> </div> </div> </div> </div> </div> </div> <div class="post-layout--right js-post-comments-component"> </div> </div> </div> </div> </div> </div> </div> <script src="../../static/js/stack-icons.js"></script> <script src="../../static/js/fromnow.js"></script> </body> </html>