【问题标题】:Not able to send values from Froala WYSIWYG editor in mysql database无法从 mysql 数据库中的 Froala 所见即所得编辑器发送值
【发布时间】:2016-11-17 12:11:50
【问题描述】:

我正在使用 Froala 所见即所得编辑器,我想将数据传递到另一个页面,但我的按钮完全禁用。当我按下按钮时,动作仍然是页面未传输。

<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>

【问题讨论】:

    标签: php mysql editor froala


    【解决方案1】:

    您必须使用 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='submitButton')

    在使用简单 SQL 查询保存时,还要注意编辑器内容中的单引号。

    【讨论】:

      【解决方案2】:

      我花了一周的时间试图解决同样的问题,答案很简单!! 编辑器的代码如下:

      <form action="save.php" method="POST">
      
      
      <textarea name="editor_content" id="myEditor"></textarea>
        <button>Submit</button>
      </form>
      
      <script>
        $(function() {
          $('#myEditor').froalaEditor({toolbarInline: false})
        });
      </script>
      

      还要确保包含所有 css 和 js 文件。

      在 save.php 文件中,您可以使用 $_POST['editor_content']; 获取数据

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2019-09-30
        • 1970-01-01
        • 2018-06-19
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多