We're a community of 1076K IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,075,987 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion
Page 2 of Article: Text Editor In PHP
Hi I have a few questions. **1) I want to put the a text editor in the admin section so I can edit the 'home page' context from the admin section which is in php language (I have no context in the admin created yet, this will be my first…

you can try fckeditor

sftranna
Newbie Poster
12 posts since Feb 2009
Reputation Points: 10
Solved Threads: 1
Skill Endorsements: 0

If you download CKeditor from ckeditor.com, you will see there is a ckeditor.php included. CKeditor replaces FCKeditor that you were used to using. Here is a page that explains how to implement (along with CKfinder which is used for managing image files):
Click Here
If you read this, you can see why CKeditor replaced FCKeditor Click Here

dannette
Newbie Poster
3 posts since Nov 2008
Reputation Points: 14
Solved Threads: 1
Skill Endorsements: 0

@ Ardav

Thanks for replying again~!!

Advanced features such as file management (uploading images etc) is one of the things that sort the mature editors from the rest

I agree.

LastMitch
Industrious Poster
4,146 posts since Mar 2012
Reputation Points: 132
Solved Threads: 334
Skill Endorsements: 45

@ sftranna

Thanks for the reply! Did you read my first post?

LastMitch
Industrious Poster
4,146 posts since Mar 2012
Reputation Points: 132
Solved Threads: 334
Skill Endorsements: 45

@ dannette

Thanks for the replying again. I will take a look at the link. Thanks

LastMitch
Industrious Poster
4,146 posts since Mar 2012
Reputation Points: 132
Solved Threads: 334
Skill Endorsements: 45

@ dannette

I took a look at the link your provided and yes this is something what I was looking for. I will follow the directions and if I have anymore questions I will post it on here. Thanks.

LastMitch
Industrious Poster
4,146 posts since Mar 2012
Reputation Points: 132
Solved Threads: 334
Skill Endorsements: 45

I use PSPad for editing websites and being able to FTP ...as in, I open up PSPad, connect ftp to my site, browse to the file I want to edit, double click to open it up, make changes, file > save to save it back to FTP.

As per a stricktly PHP based editor it's pretty simple.

I've written a very basic editor, you will probably need to modify it to work with your site, your database is probably different than what I've got here for example.

Feel free to ask me questions, I hope that it's enough to get you started with PHP, if you do anything programming you will catch on pretty quickly.

This is just the edit page, you may want to take a stab at a 'new page' page yourself and see if you can do it from what you pick up here.

Goodluck!

<?php

// Make sure you are connected to database
//include("config.php");


// Save page content / overwrite existing page
if(isset($_POST['submit'])){
$name = mysql_real_escape_string(trim($_POST['name']));
$content = mysql_real_escape_string(trim($_POST['content']));
$ud = mysql_query("UPDATE pages SET page_content='$content' WHERE page_name='$page_name' LIMIT 1");
if($ud){
echo "Page has been saved!";
}else{
echo "There was an error: ".mysql_error();
}
}

if(!empty($_GET['edit'])){
// Get the existing page content so we can then edit it
$edit = mysql_real_scape_string(trim($_GET['edit']));
$get_content = mysql_query("SELECT * FROM pages WHERE page_name='$edit' LIMIT 1");
$count_get_content = mysql_num_rows($get_content);

if($count_get_content > 0){
// We got a page back from mysql, now edit it:
$array_get_content = mysql_fetch_array($get_content); // we limited to 1 result max on line 11, so we do not need a while loop!
$content = $array_get_content['page_content'];
?>
<a href="edit.php">Cancel Changes</a><br /><br />
<form action="edit.php?edit=<?php echo $_GET['edit']; ?>" method="post">
<textarea name="content"><?php echo $content; ?></textarea>
<input type="submit" name="name" value="<?php echo $_GET['edit']; ?>" />
<input type="submit" name="submit" value="Save Page" />

</form>
<?php
}else{
echo "Sorry, but the page {$_GET['edit']} does not exist in the database. <a href=\"new.php?new={$_GET['edit']}\">Create new page?</a>";
}
}else{
//List all pages

$gp = mysql_query("SELECT * FROM pages");
$cgp = mysql_num_rows($gp);
if($cgp > 0){
while($agp = mysql_fetch_array($gp)){
extract($agp);
/* page_id page_name page_content ...these are the mysql column names*/
echo "<a href=\"edit.php?edit=$page_name\">$page_name</a><br />";
}
}else{
echo "<i>No pages</i>";

}
?>
cjohnweb
Junior Poster
102 posts since Apr 2010
Reputation Points: 26
Solved Threads: 8
Skill Endorsements: 0

@ cjohnweb

Thanks for the reply and the example!

PSPad

I never heard of it but I will look into it.

LastMitch
Industrious Poster
4,146 posts since Mar 2012
Reputation Points: 132
Solved Threads: 334
Skill Endorsements: 45

@ cjohnweb

You have some interesting websites that you created in your portfolio! It's pretty!

LastMitch
Industrious Poster
4,146 posts since Mar 2012
Reputation Points: 132
Solved Threads: 334
Skill Endorsements: 45

@ dannette

The link you provide was good, but not the one I need it's for "CKFinder" but I end up installing the "CKEditor " anyway. I didn't need the "CKFinder" I only want to understand how the "CKEditor " works. But thanks for the link!

LastMitch
Industrious Poster
4,146 posts since Mar 2012
Reputation Points: 132
Solved Threads: 334
Skill Endorsements: 45
Question Answered as of 11 Months Ago by Hearth, diafol, dannette and 6 others

CKeditor should work fine without CKfinder - it's just that the instructions for initiating the CKeditor was on the CKfinder page. That's why I sent that link. I also run it without CKfinder but used that code and it works very well.

dannette
Newbie Poster
3 posts since Nov 2008
Reputation Points: 14
Solved Threads: 1
Skill Endorsements: 0

This question has already been solved: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
 
 
© 2013 DaniWeb® LLC
Page rendered in 0.1012 seconds using 2.72MB