Reputation: 1657
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();
})();
Upvotes: 1
Views: 1444
Reputation: 39628
you need to call saveHTML()
method for yui editor before your form submission to get the value then save it :
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
see here for more details.
Upvotes: 3
Reputation: 435
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 :)
Upvotes: 0