Re: HTML vs. Plain Text Input

From: Date: Fri, 07 May 2004 08:37:23 +0000
Subject: Re: HTML vs. Plain Text Input
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-185596@lists.php.net to get a copy of this message
Hello Matt, Friday, May 7, 2004, 9:33:28 AM, you wrote: MP> Hey, I was wondering if anyone knows of any easy ways to detect for HTML MP> input. I have a textarea box that I want users to be able to input either MP> plain text or HTML code. I will later display this input data, so if the MP> user input plain text then I will replace newline characters (\r\n, \n, \r) MP> with <br> tags, but if they input HTML code I don't want to format it before MP> displaying it. Basically is there an easy way to detect HTML code in MP> inputs? If you have any suggestions, please let me know. Just one way of doing this, but... $userinput = 'blah blah <b>bold!</b> blah'; $test_html = strip_tags($userinput); if ($userinput !== $test_html) { echo 'They included html!'; } else { echo 'Plain text'; } -- Best regards, Richard Davey http://www.phpcommunity.org/wiki/296.html

« previous php.general (#185596) next »