this doesn’t work. When I enter html into the form. For instance when I enter a horizontal rule it displays in the echo output even though the $value was passed through strip_tags.
function sanitizeString($var){
$var = strip_tags($var);
$var = htmlentities($var);
return stripslashes($var);
}
foreach($_POST as $key => $value){
echo $key."<br>";
sanitizeString($value);
echo $value."<br>";
}
You aren’t actually changing
$value. You are throwing away the return value. Try$value = sanitizeString($value);.