1.2
富而不娇 , 穷则自立 -

 

需要保存到数据库就要用到addslashes这个函数!同时还是要建一张数据库表在这里也没有写太多,看看吧!

通过FROM表单提交,

具体代码如下所示:

1:

 1     <meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/>
 2 </head>
 3 <body>
 4 <form action="getValue.php" method="post">
 5     标题: <input type="text" name="title"/> <br/>
 6     <?php
 7     include("fckeditor/fckeditor.php") ;
 8      $oBasePath = $_SERVER['PHP_SELF'];
 9     $oBasePath = dirname($oBasePath)."/fckeditor/";
10     $oFCKeditor = new FCKeditor('FCKeditor1') ;
11     $oFCKeditor->BasePath    = $oBasePath;
12     $oFCKeditor->Height = "500px";
13 //    $oFCKeditor->ToolbarSet = "Basic";
14     $oFCKeditor->Create() ;
15     ?>
16     <input type="submit"  name="submit" value="提交"/>
17 </form>
18 </body>
19 </html>

2:

 1 <html>
 2 <head>
 3     <meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/>
 4 </head>
 5 <body>
 6 <?php
 7 if(isset($_POST['FCKeditor1'])){
 8     $titles= $_POST['title'];
 9     $fuggh = $_POST["FCKeditor1"];
10     $fuggh = addslashes($fuggh);//addslashes函数将引号也保存到数据库当中打印出来;
11     $conn = mysql_connect("localhost","root","") or die("数据库连接失败".mysql_error());
12     mysql_select_db("test");
13     mysql_query("set names 'utf8'");
14     $sql ="INSERT INTO `test`.`more` (`id`, `title`,`condent`)VALUES (NULL, '$titles','$fuggh')";
15     mysql_query($sql);
16     $id = mysql_insert_id();
17 //    echo $id;
18     $sql = "select * from more where id = $id";
19     $r = mysql_query($sql);
20     $row = mysql_fetch_row($r);
21 }
22 
23 ?>
24 <p>标题:<?php echo $row[1] ?></p>
25 <p>内容:<?php echo $row[2] ?></p>
26 </body>
27 </html>

 

 

 

 

 

posted on 2014-05-21 15:26  ke丶  阅读(300)  评论(0编辑  收藏  举报