Php 无法从mysql数据库中的Froala WYSIWYG编辑器发送值
我正在使用Froala WYSIWYG编辑器,我想将数据传递到另一个页面,但我的按钮被完全禁用。当我按下按钮时,动作仍然是,页面未被传输Php 无法从mysql数据库中的Froala WYSIWYG编辑器发送值,php,mysql,editor,froala,Php,Mysql,Editor,Froala,我正在使用Froala WYSIWYG编辑器,我想将数据传递到另一个页面,但我的按钮被完全禁用。当我按下按钮时,动作仍然是,页面未被传输 <div id="editor"> <?php if(!empty($_SESSION['success'])) { echo "done completely"; } // Create connection
<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>
您必须使用Jquery从编辑器中提取HTML内容。然后您可以将其发布到服务器。 Jquery代码:
$('#submitButton').click(function(e){
var helpHtml = $('div#froala-editor').froalaEditor('html.get'); // Froala Editor Inhalt auslesen
$.post( "otherPage.php", { helpHtml:helpHtml });
});
在PHP中,您将在$\u帖子中看到内容
别忘了将id属性添加到按钮(id='submitButton')
使用简单SQL查询保存时,还应注意编辑器内容中的单引号。您必须使用Jquery从编辑器中提取HTML内容。然后您可以将其发布到服务器。 Jquery代码:
$('#submitButton').click(function(e){
var helpHtml = $('div#froala-editor').froalaEditor('html.get'); // Froala Editor Inhalt auslesen
$.post( "otherPage.php", { helpHtml:helpHtml });
});
在PHP中,您将在$\u帖子中看到内容
别忘了将id属性添加到按钮(id='submitButton')
使用简单的SQL查询保存时,还要注意编辑器内容中的单引号。我花了一周时间试图解决相同的问题,答案非常简单!! 编辑器的代码如下所示:
<form action="save.php" method="POST">
<textarea name="editor_content" id="myEditor"></textarea>
<button>Submit</button>
</form>
<script>
$(function() {
$('#myEditor').froalaEditor({toolbarInline: false})
});
</script>
提交
$(函数(){
$('#myEditor').froalaEditor({toolbarInline:false})
});
还要确保包含所有css和js文件
在save.php文件中,您可以使用$\u POST['editor\u content']获取数据 我花了一个星期的时间试图解决同一个问题,答案很简单!! 编辑器的代码如下所示:
<form action="save.php" method="POST">
<textarea name="editor_content" id="myEditor"></textarea>
<button>Submit</button>
</form>
<script>
$(function() {
$('#myEditor').froalaEditor({toolbarInline: false})
});
</script>
提交
$(函数(){
$('#myEditor').froalaEditor({toolbarInline:false})
});
还要确保包含所有css和js文件
在save.php文件中,您可以使用$\u POST['editor\u content']获取数据