bryceray1121
12-29-2008, 09:48 AM
I have setup a text editor for my content managment system. Before using this text editor i had simply used forms for updating and adding to the database via POST.
I have now setup to include a text editor which is functioning however i'm not sure how to submit the data inside the text editor.
Here is my submit statement:
if($_POST['submit']) {
$sql = "UPDATE entries
SET title = '" . mysql_real_escape_string(trim($_POST['title'])) . "', body= '" . mysql_real_escape_string(trim($_POST['body'])) . "'
WHERE id = " . mysql_real_escape_string($_POST['id']) . ";";
mysql_query($sql);
Here is the text editor (used to be a form that submitted title and body)
<!--
/**********************************************************************
Version: FreeRichTextEditor.com Version 1.00.
License: http://creativecommons.org/licenses/by/2.5/
Description: Example of how to preload content into freeRTE using PHP.
Author: Copyright (C) 2006 Steven Ewing
**********************************************************************/
-->
<?php
function freeRTE_Preload($content) {
// Strip newline characters.
$content = str_replace(chr(10), " ", $content);
$content = str_replace(chr(13), " ", $content);
// Replace single quotes.
$content = str_replace(chr(145), chr(39), $content);
$content = str_replace(chr(146), chr(39), $content);
// Return the result.
return $content;
}
// Send the preloaded content to the function.
$content = freeRTE_Preload($fillrow['body'])
?>
<?php echo "Valid Entry: " . $validentry; ?>
<h1>Update</h1>
<form action="<?php echo $SCRIPT_NAME; ?>" method="post">
<input type="hidden" name="id" value="<?php echo $validentry;?>" />
<table>
<tr>
<td>Edited:</td>
<td><i><?php echo date("F jS Y g.iA", strtotime($fillrow['dateposted'])); ?></i> </td>
</tr>
<tr>
<td>Title:</td>
<td><textarea name="title" class="title">
<?= trim($fillrow['title']); ?></textarea>
</td>
</tr>
<tr>
<td>Body:</td>
<td>
<!-- Include the Free Rich Text Editor Runtime -->
<script src="js/richtext.js" type="text/javascript" language="javascript"></script>
<!-- Include the Free Rich Text Editor Variables Page -->
<script src="js/config.js" type="text/javascript" language="javascript"></script>
<!-- Initialise the editor -->
<script>
initRTE('<?= $content ?>', 'html/example.css');
</script>
</td>
</tr>
<tr>
<td></td>
<td><input type="submit" name="submit" value="Update Entry!"></td>
</tr>
</table>
</form>
Any suggestions on how to submit this data? Thanks for your time!
I have now setup to include a text editor which is functioning however i'm not sure how to submit the data inside the text editor.
Here is my submit statement:
if($_POST['submit']) {
$sql = "UPDATE entries
SET title = '" . mysql_real_escape_string(trim($_POST['title'])) . "', body= '" . mysql_real_escape_string(trim($_POST['body'])) . "'
WHERE id = " . mysql_real_escape_string($_POST['id']) . ";";
mysql_query($sql);
Here is the text editor (used to be a form that submitted title and body)
<!--
/**********************************************************************
Version: FreeRichTextEditor.com Version 1.00.
License: http://creativecommons.org/licenses/by/2.5/
Description: Example of how to preload content into freeRTE using PHP.
Author: Copyright (C) 2006 Steven Ewing
**********************************************************************/
-->
<?php
function freeRTE_Preload($content) {
// Strip newline characters.
$content = str_replace(chr(10), " ", $content);
$content = str_replace(chr(13), " ", $content);
// Replace single quotes.
$content = str_replace(chr(145), chr(39), $content);
$content = str_replace(chr(146), chr(39), $content);
// Return the result.
return $content;
}
// Send the preloaded content to the function.
$content = freeRTE_Preload($fillrow['body'])
?>
<?php echo "Valid Entry: " . $validentry; ?>
<h1>Update</h1>
<form action="<?php echo $SCRIPT_NAME; ?>" method="post">
<input type="hidden" name="id" value="<?php echo $validentry;?>" />
<table>
<tr>
<td>Edited:</td>
<td><i><?php echo date("F jS Y g.iA", strtotime($fillrow['dateposted'])); ?></i> </td>
</tr>
<tr>
<td>Title:</td>
<td><textarea name="title" class="title">
<?= trim($fillrow['title']); ?></textarea>
</td>
</tr>
<tr>
<td>Body:</td>
<td>
<!-- Include the Free Rich Text Editor Runtime -->
<script src="js/richtext.js" type="text/javascript" language="javascript"></script>
<!-- Include the Free Rich Text Editor Variables Page -->
<script src="js/config.js" type="text/javascript" language="javascript"></script>
<!-- Initialise the editor -->
<script>
initRTE('<?= $content ?>', 'html/example.css');
</script>
</td>
</tr>
<tr>
<td></td>
<td><input type="submit" name="submit" value="Update Entry!"></td>
</tr>
</table>
</form>
Any suggestions on how to submit this data? Thanks for your time!