YUI编辑器内容保存在数据库PHP中
我正在使用 YUI 编辑器。我尝试获取 textarea
值并将其保存在数据库中,但我无法这样做。这是我的代码。
@$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();
})();
I am using YUI editor. I tried to fetch the textarea
value and save it in database, but i am not able to do so. 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();
})();
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在提交表单之前,您需要调用 yui 编辑器的
saveHTML()
方法来获取值然后保存它:然后将变量
html
的内容保存在数据库中,参见 < a href="http://developer.yahoo.com/yui/editor/" rel="nofollow">此处了解更多详细信息。
you need to call
saveHTML()
method for yui editor before your form submission to get the value then save it :then save in your database the content of the variable
html
see here for more details.
没有 YUI 编辑器的情况下输入框也能工作吗?
尝试在代码开头添加 var_dump($_POST) 。这样您就可以看到哪些内容已发布到服务器。这是基本的调试:)
Does it work with the input field without YUI editor?
Try to add var_dump($_POST) at the beggining of your code. That way you will see what content was posted to the server. It's basic debugging :)