textarea addslashes confusion

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
jmut
Forum Regular
Posts: 945
Joined: Tue Jul 05, 2005 3:54 am
Location: Sofia, Bulgaria
Contact:

textarea addslashes confusion

Post by jmut »

Hi,
I really think the function

Code: Select all

addslashes()
is practically of no use in php...but.

How do you show text in html textarea tag?
What if there are quotes in the text?. What if you want to show hrefs(links) but not allow other html and the page break.
User avatar
Jenk
DevNet Master
Posts: 3587
Joined: Mon Sep 19, 2005 6:24 am
Location: London

Post by Jenk »

Code: Select all

echo '<textarea>' . htmlentities($text) . '</textarea>';
Supper Baby
Forum Commoner
Posts: 27
Joined: Tue Aug 01, 2006 11:33 pm

Post by Supper Baby »

use stripcslashes() before showing the contint.
be sure befor using add and strip slahes, the get_magic_quotes_gpc() value is zero

if it's zero then use them.
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

Start first by echoing some of the data to make sure it is not what you want to see. Then take a look at ways to change it into what you want to see. If there is HTML in the data, use the functions that were mentioned previously.
Post Reply