2016-11-17 78 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查询保存时要注意在编辑器中的内容单引号。