I have a textarea to which I apply the TinyMCE text editing plugin ... Now ... when I want to send the content of that textarea to the database, it directly sends it to me null ...
In the Head position the following script (this takes it out of the configuration of the same tinyMCE page)
<script src="https://cloud.tinymce.com/stable/tinymce.min.js?apiKey=ACA_VA_MI_KEY_DE_TINYMCE"></script>
<script>
tinymce.init({
selector:'#resumen',
language_url : '../../js/es.js'
});
tinymce.init({
selector:'#texto',
language_url : '../../js/es.js'
});
</script>
Textareas are called summary and text respectively. Now ... in textareas I have:
<div class="field">
<label>Resumen / Bajada:</label>
<textarea id="resumen" name="resumen" required>
</textarea>
</div>
that "id" what it does is bind me the tinyMCE script
Below all I have a submit button that I send by POST everything that was loaded in the form.
$error = "";
$fecha = $_POST['fecha'];
$titulo = $_POST['titulo'];
$resumen = nl2br($_POST['resumen']);
$texto = nl2br($_POST['texto']);
This I do in the process of saving ... the 'summary' and the 'text' would be the two textareas of which I define in the script
I DO NOT UNDERSTAND WHAT HAPPENS: I went through the problem clean, and did the following:
<head>
<title>My test editor - with tinyMCE and PHP</title>
<script type="text/javascript" src="tinymce/tinymce.min.js"></script>
<script type="text/javascript">
tinymce.init({
selector: "#texto",
language_url : 'es.js',
plugins: [
'advlist autolink lists charmap print',
'searchreplace code',
'table contextmenu paste code pagebreak'
],
toolbar: 'undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | pagebreak',
});
tinymce.init({
selector: "#texto2",
language_url : 'es.js',
plugins: [
'advlist autolink lists charmap print',
'searchreplace code',
'table contextmenu paste code pagebreak'
],
toolbar: 'undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | pagebreak',
});
</script>
</head>
<body>
<form method="post" action="proceso.php">
<textarea id="texto" name="texto" rows="15" cols="80"></textarea>
<textarea id="texto2" name="texto2" rows="15" cols="80"></textarea>
<br />
<input type="submit" name="save" value="Submit" />
<input type="reset" name="reset" value="Reset" />
</form>
</body>
</html>
later in the process.pho I do the following:
<?php
session_start(); //Iniciar una nueva sesión o reanudar la existente
require 'conexion.php';
$allowedTags='<p><strong><em><u><h1><h2><h3><h4><h5><h6><img><li><ol><ul><span><div><br><ins><del><small>';
if($_POST['texto']!='') {
$sContent = strip_tags(stripslashes($_POST['texto']),$allowedTags);
echo $sContent;
} else {
$sContent = "";
}
if($_POST['texto2']!='') {
$sContent2 = strip_tags(stripslashes($_POST['texto2']),$allowedTags);
echo $sContent2;
} else {
$sContent = "";
}
$sql = "INSERT INTO temp (textarea, campo1) VALUES ('$sContent', '$sContent2')";
$resultado = $mysqli->query($sql);
if($resultado) {
echo "todo perfecto";
} else{
echo "error al guardar";
}
?>
now ... it works fine ... save the data in the database, but where it should work, the submit button does not work !!! I click and nothing ... and it's practically the same code