Only run HTML (PHP) -


i'm here question on project; try explain best possible:

i have text area in user can write whatever want. problem can try kind of malicious code (js xss, example) using function:

echo htmlspecialchars($topic->getmessage(), ent_quotes, 'utf-8'); 

i thought had solved problem, remembered user can type html, , allowed.

is there function made running html , others stay text?

htmlspecialchars ok not safe insert mysql.

for mysql it's better use prepared statements, such explained here: http://bobby-tables.com/php.html

for output in page (without inserting on database), htmlspecialchars enough... provided don't decode before printing.

like cbroe suggested, use http://htmlpurifier.org/ clean html , avoid garbage in database, still must use prepared statements.

also read: http://php.net/manual/en/pdo.prepared-statements.php


Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -