Hello!
I would like to parse user inputs with PHP. I need a function which tells me if there are invalid characters in the text or not. My draft looks as follows:
<?php
function contains_invalid_characters($text) {
for ($i = 0; $i < 3; $i++) {
$text = html_entity_decode($text); // decode html entities
} // loop is used for repeatedly html encoded entities
$found = preg_match(...);
return $found;
}
?>
The function should return TRUE if the input text contains invalid characters and FALSE if not. Valid characters should be:
a-z, A-Z, 0-9, äöüß, blank space, "!§$%&/()=[]\?.:,;-_
Can you tell me how to code this? Is preg_match() suitable for this purpose? It's also important that I can easily expand the function later so that it includes other characters.
I hope you can help me. Thanks in advance!