The function I use to open the editor (I also tried without using functions).
function abrirEditor($seccion, $texto) {
$oFCKeditor = new FCKeditor('parrafada');
$oFCKeditor->BasePath = 'editor/';
$oFCKeditor->ToolbarSet = $seccion;
$oFCKeditor->Value = $texto;
$oFCKeditor->Create();
}The form to send the message.
<form name="comentario<?php echo $noticia['id']; ?>" action="<?php echo $url; ?>" method="POST">
<div class="respuesta">
<p><b>Avatar:</b></p>
<table width="100%">
<tr>
<td align="left">
<?php ponerAvatarB($avatar['avatar']); ?>
</td>
<td width="70%">
<p><select onchange="elegirAvatar(this.value);cambioImagen(this.value,'<?php echo $avatar['avatar'] ?>');">
<option selected value="1">Usar avatar por defecto</option>
<option value="2">Usar otro avatar</option>
<option value="3">Subir un nuevo avatar</option>
</select>
</p>
</td>
</tr>
</table>
<p><b>Mensaje:</b></p>
<input type="hidden" name="id" value="<?php echo $noticia['id']; ?>">
<input type="hidden" name="avatar" value="<?php echo $avatar['avatar']; ?>">
<input type="hidden" name="autor" value="<?php echo $avatar['id']; ?>">
<?php abrirEditor('Comentarios',''); ?>
<p><input type="submit" name="enviar" class="enviar" value="Enviar"></p>
</div>
</form>After the message is sent
<?php
if ($_POST['parrafada']=='') {
echo("<h1>Error</h1>");
echo("No puedes enviar un comentario vacío.");
}
else {
$ip=obtIP();
$texto=mysql_real_escape_string(trim($_POST['parrafada']),$link);
$sql='INSERT INTO comentario(id_noticia, autor, fecha, avatar, comentario, ip) VALUES("'.$_POST['id'].'","'.$_POST['autor'].'",NOW(),"'.$_POST['avatar'].'","'.$texto.'","'.$ip.'")';
mysql_query($sql, $link) or die("<h1>Error</h1>".mysql_error());
}
?>
Re: FCKeditor returns empty strings... sometimes
FCKeditor seems not to notice when I alter the initial value. For example, if $oFCKeditor->Value is set to "Example text", it'll post "Example text" even if I write something else.