RE: [PHP] Re: Testing for the presence of HTML
| From: | Matthew Luchak | Date: | Tue, 20 Nov 2001 21:48:11 +0000 |
| Subject: | RE: [PHP] Re: Testing for the presence of HTML | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-75294@lists.php.net to get a copy of this message | ||
If I understand the question correctly - came late to the thread - I
think the easiest way to do this would be to check for the presence of
"</" or as a minimum "<" when the user submits the form. You could then
pop up a confirmation dialog "This text seems to contain HTML code is
this correct? - Ah! my god, I'm advocating clippy :( ... You can then
insert a boolean to mark the file according to their response.
____________________________
Matthew Luchak
Webmaster
Kaydara Inc.
mluchak@kaydara.com
-----Original Message-----
From: Richard S. Crawford [mailto:rscrawford@mossroot.com]
Sent: Tuesday, November 20, 2001 4:29 PM
To: php-general@lists.php.net
Subject: Re: [PHP] Re: Testing for the presence of HTML
Unfortunately, I also have users entering complex HTML code such as
tables;
which, if each tag of a table is on a separate line, renders badly with
nl2br(). I mean, really badly. You have no idea.
My users range from professional web developers to people who are still
frightened by the idea of using a mouse.
At 01:20 PM 11/20/2001, Fred wrote:
>This may not actually be a problem. If you are expecting that users
may
>enter links as html you can still use nl2br and get a decent result.
The
>only time this would be a problem, would be if the users actually
entered
><BR> as they filled in the form. In my experience, it is highly
unlikely
>that a user will write their own <BR> as they fill in a form, even if
they
>do enter other html such as links.
>
>Fred
>
>Richard S. Crawford <rscrawford@mossroot.com> wrote in message
>news:5.1.0.14.0.20011120113644.02ff72a0@pop3.norton.antivirus...
>My database contains a field which may or may not contain HTML code,
>depending on what a particular user enters when they enter the data.
>
>Here's the challenge:
>
>If there is HTML code in this field, then print the text with
interpreted
>HTML. No problem at all.
>
>If there is no HTML code in the field, then I still want the data
printed
>nice and neat; the users will probably use line returns to make their
text
>look somewhat decent.
>
>So, assuming that $text contains the contents of this field, then what
I
>want to do is this:
>
> if (!HTMLin$text) then $text = nl2br($text);
>
>What's the best way to check and see if HTML is present in the field?
>
>
>Sliante,
>Richard S. Crawford
>
>http://www.mossroot.com
>AIM: Buffalo2K ICQ: 11646404 Y!: rscrawford
>MSN: underpope@hotmail.com
>
>"It is only with the heart that we see rightly; what is essential is
>invisible to the eye." --Antoine de Saint Exupéry
>
>"Push the button, Max!"
>
>
>
>
>--
>PHP General Mailing List (http://www.php.net/)
>To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
>For additional commands, e-mail: php-general-help@lists.php.net
>To contact the list administrators, e-mail:
php-list-admin@lists.php.net
Sliante,
Richard S. Crawford
http://www.mossroot.com
AIM: Buffalo2K ICQ: 11646404 Y!: rscrawford
MSN: underpope@hotmail.com
"It is only with the heart that we see rightly; what is essential is
invisible to the eye." --Antoine de Saint Exupéry
"Push the button, Max!"
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
For additional commands, e-mail: php-general-help@lists.php.net
To contact the list administrators, e-mail: php-list-admin@lists.php.net