10/10/2018, 09:19

FCKeditor update()????????

Các bạn cho mình hỏi code như thế nào để add thông tin trong FCKeditor vào DB?
VacCuChuoi viết 11:35 ngày 10/10/2018
bạn biết gắn vào chưa đã ! nếu gắn dc bạn copy code đó len xem.gùi code cho.
lúc trước có thử nhưng h wên FCeditor nó sử dụng cái gì mất.
bạn đưa code của thằng editor len ngen.
cái code hiển thị(jông textarea ý) thôi chứ đừng wang tất cả lên.
herofit viết 11:33 ngày 10/10/2018
Được gửi bởi duongdangquoc
Các bạn cho mình hỏi code như thế nào để add thông tin trong FCKeditor vào DB?
down về đã có code demo rùi xem cái là biết.
johnnie_Nguyen viết 11:27 ngày 10/10/2018
Cai nay minh da lam roi, goi cac ban tham khao:

Javascript

Method 1:
<script type="text/javascript" src="/FCKeditor/fckeditor.js"></script>
<script type="text/javascript">
var oFCKeditor = new FCKeditor('FCKeditor1');
oFCKeditor.BasePath = "/FCKeditor/";
oFCKeditor.Create();
</script>

Method 2:
<html>
<head>
<script type="text/javascript" src="/FCKeditor/fckeditor.js"></script>
<script type="text/javascript">
window.onload = function()
{
var oFCKeditor = new FCKeditor( 'MyTextarea' ) ;
oFCKeditor.BasePath = "/FCKeditor/" ;
oFCKeditor.ReplaceTextarea() ;
}
</script>
</head>
<body>
<textarea id="MyTextarea" name="MyTextarea">This is <b>the</b> initial value.</textarea>
</body>
</html>

PHP

Method 1:
<?php
include("FCKeditor/fckeditor.php");
?>
<?php
$oFCKeditor = new FCKeditor('FCKeditor1');
$oFCKeditor->BasePath = '/FCKeditor/';
$oFCKeditor->Value = 'Default text in editor';
$oFCKeditor->Create();
?>

Method 2:
<?php
include("FCKeditor/fckeditor.php") ;
?>
<html>
<head>
<title>FCKeditor - Sample</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<form action="savedata.php" method="post">
<?php
$oFCKeditor = new FCKeditor('FCKeditor1') ;
$oFCKeditor->BasePath = '/FCKeditor/';
$oFCKeditor->Value = 'Default text in editor';
$oFCKeditor->Create() ;
?>
<br>
<input type="submit" value="Submit">
</form>
</body>
</html>

Trang vidu dien hinh:

<? include("auth.php"); ?>

<?

session_start();

$pagename="add_news.php";

$pagetitle="Admin - Check Permission";

include_once("lib/lib.php");

require("lib/mydb.php");

?>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"

"http://www.w3.org/TR/html4/loose.dtd">

<html>

<head>

<title><? echo $pagetitle; ?></title>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8">

<LINK href="css/land.css" type=text/css rel=stylesheet>

<LINK media=print href="css/print2.css" type=text/css rel=stylesheet>

<link href="css/style1.css" rel="stylesheet" type="text/css">

</head>

<body bgcolor="#FDFDFD" leftMargin=0 topMargin=0 marginheight="0" marginwidth="0">

<?

include("../fckeditor/fckeditor.php") ;

require('connection.inc');



if ( Check_Right($uadpq,$act)==TRUE )

{

$today=date("d-m-Y",time());

$cert1 = "image/pjpeg"; //Jpeg type 1

$cert2 = "image/jpeg"; //Jpeg type 2

$cert3 = "image/gif"; //Gif type

$cert4 = "image/bmp"; //bmp type

$cert5 = "image/png"; //png type

$cert6 = "image/ico"; //ico type

$cert7 = "application/msword";

$cert8 = "application/vnd.ms-excel";

$cert9 = "application/pdf";

$cert10 = "application/octet-stream";

$cert11 = "application/vnd.ms-powerpoint";

$cert12 = "application/x-msdownload";

$cert13 = "text/html";

$cert14 = "text/plain";

$cert15 = "audio/x-ms-wma";

$cert16 = "audio/x-ms-mp3";

$cert17 = "audio/x-ms-mp4";

$cert18 = "video/x-ms-wmv";

$cert19 = "video/x-ms-mpeg";

$cert20 = "video/x-ms-dat";

$cert21 = "video/x-ms-avi";

$cert22 = "application/x-zip-compressed";

///////////////////////////////////////////////////////

function getFileExtension($str) {



$i = strrpos($str,".");

if (!$i) { return ""; }



$l = strlen($str) - $i;

$ext = substr($str,$i+1,$l);



return $ext;



}

if ($tieude!="")

{

$sql="insert into tintuc (ndID,tieudetin,noidungvt,noidungct,tacgia,nguonti n,ngaynhap,ngonngu,tinnong,nguoinhap,weblink) values ('$ndID','$tieude','$noidungvt','$FCKeditor1','$ta cgia','$nguontin','$today','$ngonngu','$tinnong',' $uad','$weblink')";

if(mysql_query($sql, $link))

{

$newid = mysql_insert_id();

if($img1_name!="")

{

if (($img1_type == $cert1) or ($img1_type == $cert2) or ($img1_type == $cert3) or ($img1_type == $cert4) or ($img1_type == $cert5) or ($img1_type == $cert6) or ($img1_type == $cert7) or ($img1_type == $cert8) or ($img1_type == $cert9) or ($img1_type == $cert10) or ($img1_type == $cert11) or ($img1_type == $cert12) or ($img1_type == $cert13) or ($img1_type == $cert14) or ($img1_type == $cert22))

{

$path = $HTTP_SERVER_VARS["DOCUMENT_ROOT"]."/hinhtin/hinhnho/".$newid.".".getFileExtension($img1_name);

if (!copy($img1, $path)) echo ("failed to save file viet<br>\n");

else

{

$sql = "update tintuc set hinhnho='".$newid.".".getFileExtension($img1_name) ."' where ttID=$newid";

mysql_query($sql, $link);

}

}

}

if($img2_name!="")

{

if (($img2_type == $cert1) or ($img2_type == $cert2) or ($img2_type == $cert3) or ($img2_type == $cert4) or ($img2_type == $cert5) or ($img2_type == $cert6) or ($img2_type == $cert7) or ($img2_type == $cert8) or ($img2_type == $cert9) or ($img2_type == $cert10) or ($img2_type == $cert11) or ($img2_type == $cert12) or ($img2_type == $cert13) or ($img2_type == $cert14) or ($img2_type == $cert22))

{

$path = $HTTP_SERVER_VARS["DOCUMENT_ROOT"]."/hinhtin/hinhlon/".$newid.".".getFileExtension($img2_name);

if (!copy($img2, $path)) echo ("failed to save file eng<br>\n");

else

{

$sql = "update tintuc set hinhlon='".$newid.".".getFileExtension($img2_name) ."' where ttID=$newid";

mysql_query($sql, $link);

}

}

}

?>

<script>

alert("Insert data into database successfully !");

</script>

<?

}

else echo ("Error in executing query 111!");

}

}

else

{

echo "<script>alert(\"Sorry! You are not allowed permission $act.\")</script>";

exit;

}

?>



<form action="add_news.php?act=add" name="nsp" method="post" enctype="multipart/form-data" style="padding-left:15px; padding-top:15px ">

<table align="left" width="550" border="1" bgcolor="#CAEAFE" cellpadding="2" cellspacing="2" style="border-collapse:collapse " bordercolor="#6DC6FD">

<tr>

<td width="550" valign="top" align="left">

<table align="center" width="98%" border="0" cellpadding="0" cellspacing="0">

<tr><td colspan="3" align="center" class="hoang3"><u><b>Thêm Tin tức</b></u><br><br></td></tr>

<tr>

<td width="18%" height="25" class="hoang3">Thể loại tin</td>

<td width="2%">:</td>

<td width="80%" height="25">

<?

$sql="select * from chudechinh order by ndID desc";

$rs1=mysql_query($sql, $link);

?>

<select size="1" name="ndID" class="hoang3">

<?

while ($row1=mysql_fetch_array($rs1))

{

if($ndID==$row1["ndID"])

{

?>

<option value="<?=$row1["ndID"]?>" selected><?=$row1["vietnam"]?></option>

<?

}

else

echo "<option value='".$row1["ndID"]."'>".$row1["vietnam"]."</option>";

}

?>

</select>

</td>

</tr>

<tr>

<td width="18%" height="25" class="hoang3">Tiêu đề</td>

<td width="2%">:</td>

<td width="80%" height="25"><input type="text" name="tieude" size="60" class="hoang3"></td>

</tr>

<tr>

<td width="18%" height="25" class="hoang3">Website</td>

<td width="2%">:</td>

<td width="80%" height="25"><input type="text" name="weblink" size="60" class="hoang3"></td>

</tr>

<tr>

<td width="18%" height="25" class="hoang3" valign="top">Nội dung vắn tắt</td>

<td width="2%" valign="top">:</td>

<td width="80%" height="25"><textarea cols="70" rows="2" name="noidungvt" class="hoang3"></textarea></td>

</tr>

<tr>

<td height="25" colspan="3" class="hoang3">Nội dung chi tiết<br>

<?php

$oFCKeditor = new FCKeditor('FCKeditor1') ;

$w = 700;

$h = 300;

$oFCKeditor->BasePath = '/fckeditor/';

$oFCKeditor->Height = $h;

$oFCKeditor->Width = $w;

$oFCKeditor->Value = '';

$oFCKeditor->Create() ;

?>

</td>

</tr>

<tr>

<td width="18%" height="25" class="hoang3">Hình nhỏ</td>

<td width="2%">:</td>

<td width="80%" height="25"><input type="file" name="img1" size="30" class="hoang3"></td>

</tr>

<tr>

<td width="18%" height="25" class="hoang3">Hình lớn</td>

<td width="2%">:</td>

<td width="80%" height="25"><input type="file" name="img2" size="30" class="hoang3"></td>

</tr>

<tr>

<td width="18%" height="25" class="hoang3">Tác giả</td>

<td width="2%">:</td>

<td width="80%" height="25"><input type="text" name="tacgia" size="30" class="hoang3"></td>

</tr>

<tr>

<td width="18%" height="25" class="hoang3">Nguồn tin</td>

<td width="2%">:</td>

<td width="80%" height="25"><input type="text" name="nguontin" size="30" class="hoang3"></td>

</tr>

<tr>

<td width="18%" height="25" class="hoang3">Cấp độ tin</td>

<td width="2%">:</td>

<td width="80%" height="25" class="hoang3">Tin bình thường <input type="radio" value="0" checked name="tinnong">

&nbsp;Tin nóng <input type="radio" name="tinnong" value="1"></td>

</tr>

<tr>

<td width="18%" height="25" class="hoang3">Ngôn ngữ</td>

<td width="2%">:</td>

<td width="80%" height="25" class="hoang3">Vietnam <input type="radio" value="0" checked name="ngonngu">

&nbsp;English <input type="radio" name="ngonngu" value="1"></td>

</tr>

<tr>

<td width="18%" height="25" class="hoang3">Người nhập tin</td>

<td width="2%">:</td>

<td width="80%" height="25" class="hoang2"><?=$uadpq;?></td>

</tr>

<tr>

<td width="18%" height="25" class="hoang3">Ngày nhập</td>

<td width="2%">:</td>

<td width="80%" height="25" class="hoang2"><?=$today;?></td>

</tr>

<tr>

<td colspan="3" align="center"><br>

<input type="button" name="OK" value="Save" onClick="post()" class="hoang3">

<input type="reset" name="reset" value="Cancel" class="hoang3">

</td>

</tr>

</table>

</td>

</tr>

</table>

</form>

<script language="JavaScript">

function RTELoaded(w) {

w.setToolbar("tbmode",false);

w.setToolbar("tbtable",false);

w.setToolbar("tbbar5",false);

w.setToolbar("tbimage",false);

w.setSkin("#idToolbar {border: 1px black solid; background:#C0C0C0}");

}





function post()

{

if (document.nsp.tieude.value=="")

{

alert("Tieu de khong duoc de trong");

document.nsp.tieude.focus();

return false;

}

document.nsp.submit();

}

//End-->

</script>



</body>

</html>
duongdangquoc viết 11:33 ngày 10/10/2018
Ax! Mình viết bằng asp chứ ko phải php đâu. Code của nó thì mình chưa xử lý gì hết. Ý của mình là khi user nhập text vào FCKeditor và nhấn nút save thì thông tin đó sẽ lưu vào DB thôi. Bạn nào có code asp thì cho mình với nha.

[=========> Bổ sung bài viết <=========]

Không nhất thiết phải là FCK đâu. Cái gì mà có thể cho người dùng nhập văn bản cũng đc. Có code xử ly cho mình luôn nha. Yêu cầu vẫn giống vậy luôn. Thanks!!!!!!!
Bài liên quan
0