[英]YUI editor content save in database PHP
I am using YUI editor. 我正在使用YUI编辑器。 I tried to fetch the textarea
value and save it in database, but i am not able to do so. 我试图获取textarea
值并将其保存在数据库中,但我无法这样做。 Here is my code. 这是我的代码。
@$titleidz=$_POST['title'];
@$contentidz=$_POST['editor'];
if($titleidz && $contentidz)
{
include_once('../config/config.php');
$q= "insert into tbl_page(title, content) values('$titleidz', '$contentidz')" ;
$result=mysql_query($q) or die(mysql_error());
<form action="" name="form" method="post">
<table style="table-layout: fixed;width:100%">
<tr><input class="input_text" type="text" size="50" name="title" placeholder="Enter Your Title" id="title"></td><td><span style="color:red" id="errTitle"></span></td></tr>
<tr><td><textarea id="editor" name="editor" rows="20" cols="75">fffffffff</textarea></td></tr>
<tr><td colspan=2 align="middle"><input type="submit"></td></tr>
</table>
</form>
<script>
(function() {
var Dom = YAHOO.util.Dom,
Event = YAHOO.util.Event;
var myConfig = {
height: '300px',
width: '990px',
animate: true,
dompath: true,
focusAtStart: true
};
var myEditor = new YAHOO.widget.Editor('editor', myConfig);
myEditor.render();
})();
you need to call saveHTML()
method for yui editor before your form submission to get the value then save it : 你需要在表单提交之前为yui编辑器调用saveHTML()
方法来获取值然后保存它:
YAHOO.util.Event.on('somebutton', 'click', function() {
//Put the HTML back into the text area
myEditor.saveHTML();
//The var html will now have the contents of the textarea
var html = myEditor.get('editor').value;
});
then save in your database the content of the variable html
然后将变量html
的内容保存在数据库中
Does it work with the input field without YUI editor? 没有YUI编辑器,它是否适用于输入字段?
Try to add var_dump($_POST) at the beggining of your code. 尝试在代码的开头添加var_dump($ _ POST)。 That way you will see what content was posted to the server. 这样,您将看到什么内容已发布到服务器。 It's basic debugging :) 这是基本的调试:)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.