php引入fckeditor编辑工具

1、引入编辑工具代码

<html>
<head>
    <meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/>
</head>
<body>
<form action="yong2.php" method="post">
    <?php
    include("fckeditor/fckeditor.php");  //引入文件夹fckeditor下的fckeditor.php
    $oBasePath = $_SERVER['PHP_SELF'];  //获得当前文件夹路径
//    echo $oBasePath;
    $oBasePath = dirname($oBasePath)."/fckeditor/";   //dirname获得当前文件夹路径前缀
    $oFCKeditor = new FCKeditor('FCK');
    $oFCKeditor->BasePath   = $oBasePath;   //BasePath 基础路径
    $oFCKeditor->height = "500px";
    $oFCKeditor->Create();  //创建并显示出来
    ?>
    <input type="submit" value="提交"/>
</form>
</body>
</html>

注:上面的代码中需一个叫fckeditor的文件夹,是fckeditor编辑器:可下载它的网址为http://so.360.cn/s?ie=utf-8&src=hao_search&q=fckeditor

  引入的编辑工具样式为下图所示:可直接在里面编辑内容

2、将输入的数据在另一个页面显示出来,并插入myAdMin中数据库t_yong中

<html>
<head>
    <meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/>
</head>
<body>
<?php
if(isset($_POST['FCK']));
echo $_POST['FCK'];
$fck = $_POST['FCK'];  //addslashes用于解决插入引号的问题
$t_yong = mysql_connect("localhost","root","root") or die("数据库连接失败,请检查后重新输入");
mysql_select_db("test");
mysql_query("set names 'utf8'");

$sql = "INSERT INTO `t_yong`(`id`, `content`) VALUES ('','$fck')";
mysql_query($sql);
mysql_close($t_yong);
?>
</body>
</html>

 

posted @ 2014-05-21 19:20  微笑进行时  阅读(152)  评论(0编辑  收藏  举报