note 72369 added to function.strip-tags
| From: | rodt at osu1 dot php dot net | Date: | Tue, 16 Jan 2007 15:46:56 +0000 |
| Subject: | note 72369 added to function.strip-tags | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-121799@lists.php.net to get a copy of this message | ||
I have used this function successfully to prevent bots inserting HTML to web forms. Put the
fields' contents into an array, then feed array to this function as an argument. Returns false
if HTML is included; true if there is no HTML in any of the array's values. Hope it's
helpful to someone.
/*
Checks that there is no HTML in any of provided fields.
$ary_no_html_allowed = Array to check for HTML content.
*/
function screenForm($ary_check_for_html){
// check array - reject if any content contains HTML.
foreach($ary_check_for_html as $field_value) {
$stripped = strip_tags($field_value);
if($field_value!=$stripped) { // something in the field value was HTML
return false;
}
}
return true;
}
}
----
Server IP: 83.138.144.80
Probable Submitter: 81.137.252.251
----
Manual Page -- http://www.php.net/manual/en/function.strip-tags.php
Edit -- https://master.php.net/note/edit/72369
Del: integrated -- https://master.php.net/note/delete/72369/integrated
Del: useless -- https://master.php.net/note/delete/72369/useless
Del: bad code -- https://master.php.net/note/delete/72369/bad+code
Del: spam -- https://master.php.net/note/delete/72369/spam
Del: non-english -- https://master.php.net/note/delete/72369/non-english
Del: in docs -- https://master.php.net/note/delete/72369/in+docs
Del: other reasons-- https://master.php.net/note/delete/72369
Reject -- https://master.php.net/note/reject/72369
Search -- https://master.php.net/manage/user-notes.php