Dmitry Makovetskiyd Dmitry Makovetskiyd - 5 months ago 22
PHP Question

How do you get the content from Tinymce when the form is posted?

This is how my form looks like:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>צור כתבה</title>

<script type="text/javascript" src="tiny_mce/jquery.js"></script>
<script type="text/javascript" src="tiny_mce/tiny_mce.js"></script>


<script type="text/javascript">

tinyMCE.init({
mode : "textareas",
theme : "advanced",
theme_advanced_toolbar_location : "top",
height:"1000px",
width:"800px",

editor_selector :"mceEditor"
});



tinyMCE.activeEditor.getContent();


</script>
</head>

<body>


<div align="center" id="htmlEditor">
<form >
<table>
<tr>
<td>
<textarea name="textareas" cols="40" rows="20" class="mceEditor"></textarea>
</td>
</tr>
<tr>
<td align="center">
<input type="submit" value="צור מאמר"/>
</td>
</tr>
</table>
</form>
</div>

</body>
</html>


When the form is posted, I want to fetch the data that is inside the textarea as it is and put it into the database.

The question is how do I do it, considering that I use php and $_POST..

I know that there is that function: tinyMCE.activeEditor.getContent();

But it is a javascript function. How do I fetch the data from that javascript function and put into my php code so that I will be able to use it to put into my database?!?!?

Answer

In your case you have to get it using $_POST['textareas'] because 'textareas' is the name of the textarea.

The function tinyMCE.activeEditor.getContent() is client side, so you can get the content while you are on the page (before the submit).

Anyway as Amila said, you should add the method="post" to your form.