Ckeditor - How do I "save" to the web page I am editing?
PHP Version 5.3.3-1 Ubuntu 10.10 Apache 2.2
Ckeditor 3.6.1
I can edit and save but the web page I am editing does not update ? The edited text appears in a new window. I want the web page I am editing to be updated.
ckeditor.js
, test.html
and posteddata.php
are all in the same directory /var/www/
test.html
< head>
< title>Test Page < /title >
< meta http-equiv="content-type" content="text/html; charset=utf-8"/ >
< script type="text/javascript" src="ckeditor.js">< /script >
< /head >
<开发者_开发百科; body >
< form action="posteddata.php" method="post" >
< textarea id="editor1" name="editor1" >
<p>Your text goes here</p>
< /textarea>
< script type="text/javascript" >
window.onload = function()
{CKEDITOR.replace( 'editor1' );};
< /script>
< input type="submit" value="Submit"/ >
< /form>
< /body>
< /html>
posteddata.php
< ?php
if ( isset( $_POST ) )
$postArray = &$_POST ; // 4.1.0 or later, use $_POST
else
$postArray = &$HTTP_POST_VARS ; // prior to 4.1.0, use HTTP_POST_VARS
foreach ( $postArray as $sForm => $value )
{
if ( get_magic_quotes_gpc() )
$postedValue = htmlspecialchars( stripslashes( $value ) ) ;
else
$postedValue = htmlspecialchars( $value ) ; ?>
< tr>
< th style="vertical-align: top"><?php echo htmlspecialchars($sForm); ?>
< /th>
< td><pre class="samples"><?php echo $postedValue?></pre></td>
< /tr>
< ?php }
?>
All your code does is print out what you've just typed in. It doesn't save it anywhere.
Probably the simplest way is to store the changes in a database and then load them each time.
Here's a tutorial; worth reading if you want to do anything useful in PHP: http://www.w3schools.com/php/php_mysql_intro.asp
There is a "save" plugin that submits the form. Get the submitted form and save it in your DB or on your file.
精彩评论