PDA

View Full Version : Rich Text Editor and PHP



maxman
10-28-2006, 01:37 PM
1) Script Title: Rich Text Editor (for textareas)

2) Script URL (on DD): http://www.dynamicdrive.com/dynamicindex16/richtexteditor/index.htm

3) Describe problem:

I am trying to enable users to update sections of the site easily. I have managed to get the RTE set up so that it can submit data into the database. However, when I try and retrieve it to edit it the RTE just dissapears.
How can I sort this out?

thetestingsite
10-28-2006, 04:41 PM
you may have to do addslashes or htmlentities (<spelling?) to fix that problem. That is if it only dissapears when anything with single quotes is extracted from the db then there's your problem, and the above to PHP functions should fix it.

maxman
10-28-2006, 06:18 PM
I found this code on another website that apparently fixes this problem, but I am unsure of how to incorporate it. Here is what I found:





function rteSafe($strText) {
//returns safe code for preloading in the RTE
$tmpString = $strText;

//convert all types of single quotes
$tmpString = str_replace(chr(145), chr(39), $tmpString);
$tmpString = str_replace(chr(146), chr(39), $tmpString);
$tmpString = str_replace("'", "'", $tmpString);

//convert all types of double quotes
$tmpString = str_replace(chr(147), chr(34), $tmpString);
$tmpString = str_replace(chr(148), chr(34), $tmpString);
// $tmpString = str_replace("\"", "\"", $tmpString);

//replace carriage returns & line feeds
$tmpString = str_replace(chr(10), " ", $tmpString);
$tmpString = str_replace(chr(13), " ", $tmpString);

return $tmpString;
}//function rteSafe($strText)


use the above function, which basically replaces problematic characters from the content before being input in the x.html variable


use it like this :


<rteSafe>


Can anyone tell me how I would set up this code, ie where I would put it. Thanks :)

MD version 1.0
11-20-2006, 05:49 PM
I've hooked up RTE to add content to my database.

Question is, How do I $_GET the data out so that it can be editted? What do I use? I'm new at this so I'm not sure.

Thanks in advance.

M-

drrainman6
10-06-2008, 05:39 PM
How did you get it to submit to the database? Would you mind posting some code.

mikethestone
07-17-2009, 11:02 PM
I've hooked up RTE to add content to my database.

Question is, How do I $_GET the data out so that it can be editted? What do I use? I'm new at this so I'm not sure.

Thanks in advance.

M-


Because it's a lot of data that might be in the post, use the POST method ... then the post will be hidden in a POST variable instead of using the GET method and having everything urlencoded in the address bar


<form method='post' action=''>
<textarea name='content'><?php echo rteSafe($content_string); ?>here</textarea>
<br>
<input type='submit' name='submit' value='Submit'>
</form>
<?php
if (isset($_POST['submit'])){
//write $content string to database
}
?>

Does this help you? I don't mind helping with this topic as I have been working on these issues for a while.


Mike

schmitanu
04-03-2010, 09:24 AM
Because it's a lot of data that might be in the post, use the POST method ... then the post will be hidden in a POST variable instead of using the GET method and having everything urlencoded in the address bar


<form method='post' action=''>
<textarea name='content'><?php echo rteSafe($content_string); ?>here</textarea>
<br>
<input type='submit' name='submit' value='Submit'>
</form>
<?php
if (isset($_POST['submit'])){
//write $content string to database
}
?>

Does this help you? I don't mind helping with this topic as I have been working on these issues for a while.


Mike


Hi,

Use this code in your php
$content_string=addslashes(preg_replace('`[\r\n]`','',$content_string));


Eddie

rinus82
04-16-2010, 12:05 AM
In internet explorer when I type:

<div id="4"></div>


Then the "" disappears and I get

<div id=4></div>


Is there a way that I can keep these "" qoutes with div and also class ?

thx in advance!

chaitra
05-12-2011, 11:14 AM
1) Script Title: Rich Text Editor (for textareas)

2) Script URL (on DD): http://www.dynamicdrive.com/dynamici...itor/index.htm

3) Describe problem:

I am trying to enable users to update sections of the site easily. I have managed to get the RTE set up so that it can submit data into the database. However, when I try and retrieve it to edit it the RTE just dissapears.
How can I sort this out?

Hi Friends,even am facing same problem as above,i dont no what to do any one can help me

strelexii
07-27-2012, 01:57 PM
<tr>
<td>
</td>
<td>
<div style="padding-left: 0px;"><textarea name="spaceaboutmeTemp" id="textAreaSpaceAboutMe" cols="10" rows="6" style="width: 63%; display: none;">{user.space.aboutme}</textarea>
</div>
</td>
</tr>
<tr>
<td>
</td>
<td>
<script language="JavaScript" type="text/javascript">
var s = document.getElementById('textAreaSpaceAboutMe').value;
writeRichText('spaceaboutme', s, 550, 150, true, false);
</script>
</td>
</tr>
*see this it should help
I am creating a new textarea that is hidden and in that textarea is going the php post. After this with javascript I am giving the content from the hidden textarea to the rich text editor and it's workint in this way.

jscheuer1
07-27-2012, 03:37 PM
Please start a new thread for a new question.