note 52569 added to function.htmlspecialchars

From: Date: Fri, 06 May 2005 05:06:05 +0000
Subject: note 52569 added to function.htmlspecialchars
Groups: php.notes 
Request: Send a blank email to php-notes+get-88984@lists.php.net to get a copy of this message
If there're any n00bs out there looking for a way to ensure that no html/special chars are getting sent to their databases/put through forms/etc., this has been doing the trick for me (though being at least slightly n00bish, if this won't always work perhaps someone will ammend :-) function checkforchars ($foo) { if ($foo === htmlspecialchars($foo)) { return "Valid entry."; } else { return "Invalid entry."; } } ---- Manual Page -- http://www.php.net/manual/en/function.htmlspecialchars.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+52569 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+52569&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+52569&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+52569&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+52569&report=yes&reason=useless Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+52569&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+52569&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#88984) next »