1

i want to update mysql by using a wysiwyg inside a form i put a wysiwyg in my page inside a form and defined it's id="editor" like this:

<form Method="post" action="post.php">
<input type="text" name="title" />
<div id="editor"></div>
<input type="submit" name="update" value="update">
</form>

and in post.php file:

<?php
 if (isset($_POST['update'])){
 $title=$_POST['title'];
 $body=$_POST['editor'];
 mysql_connect("x", "y","z")or die (mysql_error());
 mysql_select_db('t')or die (mysql_error());
 mysql_query("UPDATE news SET title='$title', body='$body' WHERE  `id`='$_GET[update]'");
 mysql_close();
 header("location:new_page.php"); 
 ?>

the proplem is the first input updated in mysql but $body doesn't have the sam value of wysiwyg or it doesn't update in mysql ?? and also the wysiwyg editor recomended a div to write inside an edit

ArsanGamal
  • 158
  • 1
  • 10

2 Answers2

0

assuming you are using TinyMCE - you must force the textarea to update from the editor in a form submit handler.

jQuery and TinyMCE: textarea value doesn't submit

Community
  • 1
  • 1
Tim
  • 8,036
  • 2
  • 36
  • 52
0

"editor" is not an input so, instead of <div id="editor"> you need <textarea id="editor" name="editor"></textarea>

vectorialpx
  • 587
  • 2
  • 17