| ★ wanayoo — archive 1999 http://www.phpbuilder.com/columns/ying20000718.php3 | Nouvelle recherche | Portail wanayoo |
|
columns
forumsWindows Help
|
Displaying Formatted User Input
Dangers of Unfiltered OutputIf you just took the user's input and displayed it as is, you may break your webpage. For example, someone can maliciously embed javascript in their comment like: This is my comment.
<script language="javascript:
alert('Do something bad here!')">.
Even if the user had no bad intentions, they may accidentally put some
HTML that breaks your site layout. For example if you displayed the
user's input in a table and they included an improperly nested </table>
tag, your page appears broken.
Displaying Plain Text OnlyThe easiest solution would be to only display plain text in the comment. Using the htmlspecialchars() function, you convert all the special characters into HTML entites. For example <b> would become <b>, turning it into text instead of an HTML tag. This guarantees that there are no HTML markups in the comment that would produce unwanted output. This is an okay solution if your guests don't mind entering in only plain text, but it would be a lot better if you gave them some formatting abilities.
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Columns / Articles | Tips / Quickies | News Linking and RSS Feeds | Shared Code Library | Mail Archives | Support / Discussion Forums | Get Started! Links | Contribute! | Jobs / Resumes | PHP Manual
Contact (non support questions)
Copyright 2000 internet.com Corp.
All Rights Reserved. Legal Notices,
Reprints.
Privacy Policy
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|