RE: [PHP] coding special characters in html

From: Date: Sun, 17 Nov 2002 23:19:43 +0000
Subject: RE: [PHP] coding special characters in html
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-124844@lists.php.net to get a copy of this message
> I'm cooking tothether a tiny php html editor right now, (textarea kind > of thing). To treat the text properly I need to encode characters like > '"', '<', '>', and friends into something that > doesn't confuse the > browser. Htmlentities() or htmlspecialchars() > By the way, do you think encoding and decoding special characters like > this may replace addslashes() and stripslashes()? The html pages will > be stored in a MySQL database. No. There is no HTML entity for the single quote, so those will remain unchanged. If you use all double quotes for string delimiters in your queries, then you could skip addslashes(). > Also, addslashes() will reduce the chance of bad stuff being passed to > MySQL. But is there a function which stops client-side scripts in > whatever is entered by the user? No, not really. Using strip_tags() or htmlentities() is the best way to go on user data. It will prevent the HTML or JS that's in the input from being evaluated. ---John Holmes...

« previous php.general (#124844) next »