Ckeditor - 如何“保存”到我正在编辑的网页?
PHP 版本 5.3.3-1 Ubuntu 10.10 Apache 2.2
Ckeditor 3.6.1
我可以编辑并保存,但我正在编辑的网页没有更新?编辑后的文本出现在新窗口中。我希望更新我正在编辑的网页。
ckeditor.js
、test.html
和 posteddata.php
均位于同一目录 /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 }
?>
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 }
?>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您的代码所做的只是打印出您刚刚输入的内容。它不会将其保存在任何地方。
也许最简单的方法是将更改存储在数据库中,然后每次加载它们。
这是一个教程;如果您想在 PHP 中做任何有用的事情,值得一读: http://www.w3schools.com/php /php_mysql_intro.asp
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.