Home > Bookmarks, Networking, PhP, Tech > Remove HTML tags from POST and GET – PHP

Remove HTML tags from POST and GET – PHP

How to remove/Strip HTML tags from php $_POST variable:

foreach ($_POST as $key => $value) {
$_POST[$key] = addslashes(strip_tags($value));
}
foreach ($_GET as $key => $value) {
$_GET[$key] = addslashes(strip_tags($value));
}

  1. strip_tags – tries to return a string with all HTML and PHP tags stripped from a given string. HTML comments and PHP tags are also stripped. This is hardcoded and can not be changed with allowable_tags
  2. addslashes – Returns a string with backslashes before characters that need to be quoted in database queries etc. These characters are single quote (’), double quote (”), backslash (\) and NUL (the NULL byte). It essentially runs addslashes() or mysql_real_escape_string() on all GET, POST, and COOKIE data.
  1. No comments yet.
  1. No trackbacks yet.
GoCache - ByREV-Cache v1.0 - live served in : 0.214274 sec (gzip)