textarea and file_get_contents problem!

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
Joe
Forum Regular
Posts: 939
Joined: Sun Feb 29, 2004 1:26 pm
Location: UK - Glasgow

textarea and file_get_contents problem!

Post by Joe »

I am using file_get_contents() to read the contents of a file into a textarea, however I have discovered a small problem. Everytime the textarea tag is within the actual textarea itself it cuts off and the html starts displaying all over the page. Can someone please help here?.

Regards


Joe
kenrbnsn
Forum Newbie
Posts: 13
Joined: Tue Jul 01, 2003 3:34 pm
Location: Hillsborough, NJ USA

Post by kenrbnsn »

Apply htmlentities() to the string before displaying it. This will change any angle brackets and other special HTML punctuation to the corresponding "words". i.e. "<" to < ">" to >

Then your text will display correctly.
User avatar
Joe
Forum Regular
Posts: 939
Joined: Sun Feb 29, 2004 1:26 pm
Location: UK - Glasgow

Post by Joe »

I did think of that but this edits files aswell. Will this not disturb the overall file?. I will try it out for once :)
rehfeld
Forum Regular
Posts: 741
Joined: Mon Oct 18, 2004 8:14 pm

Post by rehfeld »

the browser will reinterpret things when submitting the form. it should work.
ianlandsman
Forum Newbie
Posts: 24
Joined: Thu Dec 30, 2004 9:50 pm
Location: New York

Post by ianlandsman »

Yes that should always work, when the browser transforms the special chars the transformed characters will be submitted.
Post Reply