Line 27: | Line 27: | ||
The editor is now ready to be used. Just open the page in your browser to see it at work. | The editor is now ready to be used. Just open the page in your browser to see it at work. | ||
− | === Complete Sample | + | === Complete Sample === |
+ | |||
<pre><?php | <pre><?php | ||
include_once("fckeditor/fckeditor.php") ; | include_once("fckeditor/fckeditor.php") ; | ||
Line 33: | Line 34: | ||
<html> | <html> | ||
<head> | <head> | ||
− | <title>FCKeditor - Sample</title> | + | <title>FCKeditor - Sample</title> |
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> | <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> | ||
</head> | </head> | ||
<body> | <body> | ||
− | <form action="sampleposteddata.php" method="post" target="_blank"> | + | <form action="sampleposteddata.php" method="post" target="_blank"> |
<?php | <?php | ||
$oFCKeditor = new FCKeditor('FCKeditor1') ; | $oFCKeditor = new FCKeditor('FCKeditor1') ; | ||
Line 44: | Line 45: | ||
$oFCKeditor->Create() ; | $oFCKeditor->Create() ; | ||
?> | ?> | ||
− | <br> | + | <br> |
− | <input type="submit" value="Submit"> | + | <input type="submit" value="Submit"> |
− | </form> | + | </form> |
</body> | </body> | ||
</html> | </html> | ||
− | </pre> | + | </pre> |
+ | |||
"FCKeditor1" is the name used to post the editor data on forms. | "FCKeditor1" is the name used to post the editor data on forms. | ||
Revision as of 09:04, 17 January 2008
It is very easy to use FCKeditor in your php web pages. Just follow these steps.
Contents
Integration step by step
Step 1
The first thing to do is to include the "PHP Integration Module" file in the top of your page as in the example below:
<?php include_once("fckeditor/fckeditor.php") ; ?>
Of course the include path refers to the place where you have installed your FCKeditor.
Step 2
Now the FCKeditor is available and ready to use. So, just insert the following code in your page to create an instance of the editor inside a <FORM>:
<?php $oFCKeditor = new FCKeditor('FCKeditor1') ; $oFCKeditor->BasePath = '/fckeditor/' ; $oFCKeditor->Value = '<p>This is some <strong>sample text</strong>. You are using <a href="http://www.fckeditor.net/">FCKeditor</a>.</p>' ; $oFCKeditor->Create() ; ?>
Step 3
The editor is now ready to be used. Just open the page in your browser to see it at work.
Complete Sample
<?php include_once("fckeditor/fckeditor.php") ; ?> <html> <head> <title>FCKeditor - Sample</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> </head> <body> <form action="sampleposteddata.php" method="post" target="_blank"> <?php $oFCKeditor = new FCKeditor('FCKeditor1') ; $oFCKeditor->BasePath = '/fckeditor/' ; $oFCKeditor->Value = '<p>This is some <strong>sample text</strong>. You are using <a href="http://www.fckeditor.net/">FCKeditor</a>.</p>' ; $oFCKeditor->Create() ; ?> <br> <input type="submit" value="Submit"> </form> </body> </html>
"FCKeditor1" is the name used to post the editor data on forms.
Handling the posted data
The editor instance just created will behave like a normal <INPUT> field in a form. It will use the name you've used when creating it (in the above sample, "FCKeditor1"). So, if you have magic quotes enabled, retrieve its value by doing something like this:
$sValue = stripslashes( $_POST['FCKeditor1'] ) ;
Additional information
- You can find some samples on how to use the editor in the "_samples/php" directory of the distributed package.