title: Insert data from iframe/textarea into db using php and java
body: <p>I can not insert data which has already been designed/written on an iframe. My code is below.</p>
  
  <p>I tried changing the iframe to a textarea. This seemed to work, but I could not add formatting like bold, italic, different font sizes, etc.</p>
  
  <p>Please help correct my code.</p>
  
  <pre><code>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
  &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
      &lt;head&gt;
          &lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8" /&gt;
          &lt;title&gt;Untitled Document&lt;/title&gt;
          &lt;link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css"&gt;
          &lt;!-- &lt;script type="text/javascript" src="http://js.nicedit.com/nicEdit-latest.js"&gt;&lt;/script&gt; &lt;script type="text/javascript"&gt;
              bkLib.onDomLoaded(function() { nicEditors.allTextAreas() });
          &lt;/script&gt;--&gt;
      &lt;/head&gt;
      &lt;style&gt;
          .image{
              border-radius:50%;
          }
      &lt;/style&gt;
  
      &lt;script&gt;
          function enableEditMode(){
              TextField.document.designMode="On";
          }
          //function ya buttun zote 
          function boldCmd(command){
              TextField.document.execCommand(command, false, null)
          }
          //function ya font name and fontsize
          function execCommandWithArg(command, arg){
              TextField.document.execCommand(command, false, arg)
          }
      &lt;/script&gt;
  
      &lt;body onload="enableEditMode();"&gt;
          &lt;form action="upload.php" method="post" enctype="multipart/form-data" &gt; 
              &lt;input type="file" name="image" /&gt;
              &lt;div&gt;
                  &lt;button name="al" onclick="boldCmd('bold');" type="button"&gt;&lt;i class="fa fa-bold"&gt;&lt;/i&gt;&lt;/button&gt;
                  &lt;button onclick="boldCmd('italic');" type="button"&gt;&lt;i class="fa fa-italic"&gt;&lt;/i&gt;&lt;/button&gt;
                  &lt;button onclick="boldCmd('justifyCenter');" type="button"&gt;&lt;i class="fa fa-align-center"&gt;&lt;/i&gt;&lt;/button&gt;
                  &lt;button onclick="boldCmd('justifyLeft');" type="button"&gt;&lt;i class="fa fa-align-left"&gt;&lt;/i&gt;&lt;/button&gt;
                  &lt;button onclick="boldCmd('justifyRight');" type="button"&gt;&lt;i class="fa fa-align-right"&gt;&lt;/i&gt;&lt;/button&gt;
                  &lt;button onclick="boldCmd('justifyFull');" type="button"&gt;&lt;i class="fa fa-align-justify"&gt;&lt;/i&gt;&lt;/button&gt;
                  &lt;button onclick="boldCmd('cut');" type="button"&gt;&lt;i class="fa fa-cut"&gt;&lt;/i&gt;&lt;/button&gt;
                  &lt;button onclick="boldCmd('copy');" type="button"&gt;&lt;i class="fa fa-copy"&gt;&lt;/i&gt;&lt;/button&gt;
                  &lt;button onclick="boldCmd('undo');" type="button"&gt;&lt;i class="fa fa-undo"&gt;&lt;/i&gt;&lt;/button&gt;
                  &lt;button onclick="boldCmd('redo');" type="button"&gt;&lt;i class="fa fa-repeat"&gt;&lt;/i&gt;&lt;/button&gt;
                  &lt;button onclick="boldCmd('underline');" type="button"&gt;&lt;i class="fa fa-underline"&gt;&lt;/i&gt;&lt;/button&gt;
                  &lt;br /&gt;
  
                  &lt;select onchange="execCommandWithArg('fontName', this.value);"&gt;
                      &lt;option value="Arial"&gt;Arial&lt;/option&gt;
                      &lt;option value="Times new Roman"&gt;Times New Roman&lt;/option&gt;
                      &lt;option value="Agency FB"&gt;Agency FB&lt;/option&gt;
                  &lt;/select&gt;
  
                  &lt;select onchange="execCommandWithArg('fontSize', this.value);"&gt;
                      &lt;option value="1"&gt;1&lt;/option&gt;
                      &lt;option value="2"&gt;2&lt;/option&gt;
                      &lt;option value="3"&gt;3&lt;/option&gt;
                      &lt;option value="4"&gt;4&lt;/option&gt;
                      &lt;option value="5"&gt;5&lt;/option&gt;
                      &lt;option value="6"&gt;6&lt;/option&gt;
                      &lt;option value="7"&gt;7&lt;/option&gt;
                  &lt;/select&gt;
              &lt;/div&gt;
              &lt;iframe   name="TextField" style="width:500px; height:300px;"&gt;&lt;/iframe&gt;
              &lt;input type="submit" name="submit" /&gt;
          &lt;/form&gt;
          &lt;?php
          if(isset($_POST["submit"])){
              $con = mysqli_connect("localhost","root","","image") or die("not");   
              $TextField1=$_POST['TextField'];
              $target_dr = "upload/";
              $target_file = $target_dr . basename($_FILES["image"]["name"]);
              if (move_uploaded_file($_FILES["image"]["tmp_name"], $target_file)) 
              {
                  echo "The file ". basename( $_FILES["image"]["name"]). " has been uploaded.";
              } else {
                  echo "Sorry, there was an error uploading your file.";
              }
              $image=basename( $_FILES["image"]["tmp_name"]); 
              $sql="INSERT INTO picha(image,file,title) 
              VALUES('$image','$target_file','$TextField1')";
              mysqli_query($con,$sql);
          }
          $sql2="SELECT * FROM picha ORDER BY id DESC";
          $result= mysqli_query($con,$sql2);
          if($result-&gt; num_rows &gt; 0){
              echo "&lt;table&gt;";
              while($row=$result-&gt;fetch_assoc()){
                  echo"&lt;tr&gt;";
                  echo "&lt;td&gt;&lt;img class='image' src='".$row["file"]."' height='190' width='190'/&gt;&lt;/td&gt;&lt;td&gt;".$row["title"]."&lt;/td&gt;[enter image description here][1] &lt;/tr&gt;";
              }
              echo "&lt;/table&gt;"; 
          }
          mysqli_close($con);
          ?&gt;
      &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>