I need to filter user input to only alphanumeri, commas, fullstop and spaces.
I actually tried this code below but other unwanted characters are going through.
if(!preg_match('/^[,. 0-9A-Za-z]/', $input)
{
echo "invalid";
}
How can i enable the input to strictly accept only these characters stated above?
The negation character (
^) needs to go inside of the character class: