2016-11-17 32 views
1

我正在使用Froala所見即所得的編輯器,我想將數據傳遞到另一個頁面,但我的按鈕已完全禁用。當我按下按鈕時,動作仍然是不傳輸的頁面。無法從MySQL數據庫中的Froala WYSIWYG編輯器發送值

<div id="editor"> 
     <?php 

     if(!empty($_SESSION['success'])) 
     { 
      echo "done completely"; 
     } 
       // Create connection 
       $conn = mysqli_connect("localhost", "root", "", "test"); 
       // Check connection 
       if (!$conn) { 
       die("Connection failed: " . mysqli_connect_error()); 
       } 

       else{ 
       $sql = "select * from user_login where id= 6"; 
       $result = mysqli_query($conn, $sql); 

       if(mysqli_num_rows($result)>0) 
       { 

        while($row = mysqli_fetch_assoc($result)){ 



     ?> 
     <form action='try.php' method='post' > 
      <textarea id='edit' style="margin-top: 30px;" placeholder="Type some text" name='user_name'> 
      <?php echo $row["user_name"] ; ?> 
      </textarea> 


     <input name='submit' type="submit" value='Success' class="btn btn-success" /> 
     </form> 

      <?php 

        } 
       } 
      } 

     ?> 
     </div> 

回答

0

您必須使用Jquery從編輯器中提取HTML內容。比你可以發佈到你的服務器。 https://www.froala.com/wysiwyg-editor/examples/getHTML

jQuery代碼:

$('#submitButton').click(function(e){ 
    var helpHtml = $('div#froala-editor').froalaEditor('html.get'); // Froala Editor Inhalt auslesen 
    $.post("otherPage.php", { helpHtml:helpHtml }); 
}); 

在PHP中,你會在你的$ _ POST的內容。

不要忘記的ID屬性添加到您的按鈕(ID =「提交按鈕」)

而且具有簡單的SQL查詢保存時要注意在編輯器中的內容單引號。