allow HTML in text area - PHP

Postby hypno » Sun Nov 13, 2011 9:56 pm
I am working on php based site.( :( and I am a newbie in PHP) .

A upload form is part of the site. When tested submiting the form, whatever HTML tag I input , it is not rendering HTML but simple plain text with tags like this <b>Bold</b> and not like Bold.

I searched whole folders and php files for "strip_tags", then disabled it. However it still not rendering HTML upon form submission.

I want to enable at least 1 text input area to be html tag acceptable. At least <a> tag.

Any clues? is there any other fuction which has disabled HTML tag input? Or do I need to enable anything in the database?

Sorry I dont have much experience in this matter, I am learning slowly.

Thanks for all for reading this.

Member Avatar

I don't follow what you're trying to do. Are you typing/pasting html format text into a textarea and then posting the form?
You then pick this up in the form of something like $_POST

What do you do then? If you use htmlentities() or htmlspecialchars() is will change <, > etc to &lt; and &gt; html encoded characters. It shouldn't do this by itself.

If you want to save this to DB in html encoded format, that's OK - you can change it back for output thus:

echo html_entity_decode($var);


echo htmlspecialchars_decode($var);

An advantage of storing html encodeds and echoing as are is for showing html (and other markup/languages) as code. But I don't think you need this.

You should search for '<script' though - you need to strip that if possible as it could be malicious. In addition if you're not using PDO or MySQLi, you'll need to use mysql_real_escape_string() to prevent problems with the query itself.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.