473,790 Members | 2,850 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

text editor inside a form textarea ?

I want a text editor inside a form's textarea,

So I would see html markup and html entities - just like a text editor.
I also would want to be able to edit it all just like a text editor -
this is done in PHPMyadmin for example...is there an easy way to do this?

In a way i'm asking the browser to suspend rendering markup.
Jul 17 '05 #1
9 9363
euh...
echo "<textarea name='field1'>$ yourfield</textarea>";

??

Rod

"Hal Halloway" <Ha******@nospa m.net> a écrit dans le message de news:
zvCLd.1479$Kj4. 1311@trnddc09.. .
I want a text editor inside a form's textarea,

So I would see html markup and html entities - just like a text editor. I
also would want to be able to edit it all just like a text editor - this
is done in PHPMyadmin for example...is there an easy way to do this?

In a way i'm asking the browser to suspend rendering markup.

Jul 17 '05 #2
In article <41************ ***********@new s.club-internet.fr>,
"WebRod" <no****@bouygte l.fr> wrote:
euh...
echo "<textarea name='field1'>$ yourfield</textarea>";

??

Rod

"Hal Halloway" <Ha******@nospa m.net> a écrit dans le message de news:
zvCLd.1479$Kj4. 1311@trnddc09.. .
I want a text editor inside a form's textarea,

So I would see html markup and html entities - just like a text editor. I
also would want to be able to edit it all just like a text editor - this
is done in PHPMyadmin for example...is there an easy way to do this?

In a way i'm asking the browser to suspend rendering markup.


I've see such things but they're written in Javascript and only work on
IE:

http://sniptools.com/dhtml_editor.php

--
DeeDee, don't press that button! DeeDee! NO! Dee...

Jul 17 '05 #3
Hal Halloway wrote:
I want a text editor inside a form's textarea,

So I would see html markup and html entities - just like a text editor.
I also would want to be able to edit it all just like a text editor -
this is done in PHPMyadmin for example...is there an easy way to do this?

In a way i'm asking the browser to suspend rendering markup.


I think this is what you are after:
<textarea><?p hp echo htmlentities($t he_code_string) ?></textarea>

That way, all HTML code will not be rendered (because "<" is replaced
with "&lt;" etc.), but it will show up as if you were viewing the source
of the document...

If that's not what you are after, take a look at this:
http://www.koivi.com/WYSIWYG-Editor/
Jul 17 '05 #4
> I think this is what you are after:
<textarea><?p hp echo htmlentities($t he_code_string) ?></textarea>

That way, all HTML code will not be rendered (because "<" is replaced with
"&lt;" etc.), but it will show up as if you were viewing the source of the
document...


Actually you don't need to use htmlentities.
Because it is already in <textarea></textarea> it works fine!
So:
<textarea><?p hp echo $the_code_strin g ?></textarea>
OR
<?php echo htmlentities($t he_code_string) ?>
But no need of:
<textarea><?p hp echo htmlentities($t he_code_string) ?></textarea>

Rod


Jul 17 '05 #5
WebRod <no****@bouygte l.fr> wrote:
Actually you don't need to use htmlentities.
Because it is already in <textarea></textarea> it works fine!
So:
<textarea><?p hp echo $the_code_strin g ?></textarea>
OR
<?php echo htmlentities($t he_code_string) ?>
But no need of:
<textarea><?p hp echo htmlentities($t he_code_string) ?></textarea>


So what will happen is $the_code_strin g just happens to have the string
"</textarea>" in it?

Not escaping is the first step towards XSS.

Jul 17 '05 #6
Sorry if this posts twice, but it didn't show up through my reader, so
I had to use GG...
Unless you have another textarea in it....

<?php
$string='<b>Thi s</b> has a textarea: <textarea></textarea> This is bad
for the page.';
?>
<textarea><?p hp echo $string ?></textarea>

Also, I think that if you don't use htmlentities it won't validate via
W3C.

Jul 17 '05 #7
WebRod wrote:
I think this is what you are after:
<textarea><?p hp echo htmlentities($t he_code_string) ?></textarea>

That way, all HTML code will not be rendered (because "<" is replaced with
"&lt;" etc.), but it will show up as if you were viewing the source of the
document...

Actually you don't need to use htmlentities.
Because it is already in <textarea></textarea> it works fine!
So:
<textarea><?p hp echo $the_code_strin g ?></textarea>
OR
<?php echo htmlentities($t he_code_string) ?>
But no need of:
<textarea><?p hp echo htmlentities($t he_code_string) ?></textarea>


Never omit htmlentities when outputting untrusted content to your pages.
It doesn't matter where you place it, it can be harmful even inside an
HTML comment.
Jul 17 '05 #8
> Never omit htmlentities when outputting untrusted content to your pages.
It doesn't matter where you place it, it can be harmful even inside an
HTML comment.


yes, you're perfectly right!!
I was thinking only about "format" tags like <h1>,<font> etc etc.

but you're right, it's always better to use htmlentities!!
I apologize for my wrong answer :(

Rod
Jul 17 '05 #9
This works OK and is XSS-safe:

<textarea><?p hp echo htmlspecialchar s($string); ?></textarea>

Or, if you want, that even if due to impossibility to represent some
characters in document charset browser had encoded them into &#nnn;
form they anyway will be shown as they were typed:

<textarea><?p hp echo preg_replace('/&amp;(#\d{1, 5}|[a-z]{1,10});/i',
'&\1;', htmlspecialchar s($string)); ?></textarea>

Both examples works fine in IE and Mozilla Firefox. Second example will
make some problems with Opera versions before 7.5 and there it'll be
hard to use &#-encodings for characters outside the document's charset.

Jul 17 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
5392
by: Pete Mahoney | last post by:
Ok I use a textarea to store data input by the user, and then upon them clicking the submit button I store this data to a database. The problem is once the user inputs too much data (about 3 paragraphs or 2020 characters) when they click on the submit button nothing happens. When I say nothing happens I mean just that, nothing at all happens the page just sits there as if nothing at all happened. If I remove one line for the textarea,...
1
4980
by: amirkargerweb | last post by:
I want to do this: <textarea> perl <font color="FF0000"> $thing_to_get=17; </font> More Perl code using $thing_to_get </textarea>
1
3772
by: IkBenHet | last post by:
Hello, I found this script to create a simple rich text form (http://programmabilities.com/xml/index.php?id=17): <html> <head> <title>Rich Text Editor</title> </head> <body>
2
2469
by: Michael | last post by:
Question 1 ---------------- I am writing an advanced BBCode system for my forums and I would like to be able to find where the cursor was positioned last in the text so I could insert the BBCode there. Question 2 ---------------- Again I am writing an advanced BBCode system for my forums and I would like to make is so that when someone puts in a tag it goes bold, so
0
1806
by: VorTechS | last post by:
I'm having a problem with an inherited label, applying text rotation to aligned text. If text rotation is applied to the aligned text, the alignment goes 'nuts'. I can find no logic to what is happening. I've built the following code from several examples on the web, if you remove the rotation then alignment works fine: Imports System.ComponentModel
0
3561
by: karen987 | last post by:
Could someone please tell me what code to add here? I have a weblog, with daily news which readers can add comments to, which are stored in a database. The form to add the comments is on an ASP page, (see code below). There is a small box, where readers can type a comment. What i want to do is to add a simple text editor, nothing too elaborate. A toolbar above the text area, should suffice, and it should be the same size as the box obviously. ...
36
9348
by: karen987 | last post by:
My newsweblog has ASP pages with news articles and a commenting system. The comments are posted, and to read them the reader clicks on the headline of the comment, and it opens up in a pop up window. I added this "whizzywig rich text editor" to the comments textbox where readers comment on articles. Whizzywig is a javascript rich text editor, and appears to work fine. I type the comment using the editor when i need to and then click...
11
5384
by: karen987 | last post by:
I have a web page which used to work fine until i added a rich text editor. the pages are in ASP and it is a news weblog, with a comments section where people click the headline of a comment and it opens into a pop up page ccalled "comment_view.asp" which has a reply button. If anyone wants to reply to the message, they click reply and it takes them to the parent page (view.asp) where there is a form for them to fill in,and submit the...
2
1936
by: divyac | last post by:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> <script type="text/javascript"> function append(){ var a = document.getElementById("fname").value var b = document.getElementById("lname").value...
0
9512
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10200
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10145
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9986
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9021
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5422
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5551
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4094
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2909
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.