Forum Moderators: coopster

Message Too Old, No Replies

How not to parse HTML from within a PHP script

         

druidjaidan

11:00 am on Jun 29, 2007 (gmt 0)

10+ Year Member



I'm writing my website backend. This consists of a series of pages for adding and updating information about widgets to a database. Most of the pages have bene very simple, however I elected that three fields would accept HTML as there data by necessity.

These three fields contain a manufactures description of the item, a description written specifically by the company, and lastly the spec sheet on the product.

I'm designing the back end page that will allow modification of existing database items. I'm using <textarea> tags for the data. The problem being that I believe if I write a line like:

echo "<textarea name=\"$fieldname[$i]\" rows=\"5\" cols=\"25\">$thevalue[$i]</textarea>

$theValue will be interpreted as the HTML it is instead of displaying the HTML so it can be edited and resaved to the DB. I haven't finished all the entire script so I haven't been able to test that theory yet, so if I'm wrong I'd be happy to hear it...if I'm right how can I get around it?

darrenG

11:14 am on Jun 29, 2007 (gmt 0)

10+ Year Member



Text displayed in a text area is treated as plain text and will not render the html contained in it.

Any value stored in a variable will not be parsed as html unless explicitly instructed to do so like:

print($variable_containing_html);

So, sleep easy, because you're wrong :)