Would very much appreciate some help. My hosts server-side updates have caused my comment form to throw two validation errors. First one is: preg_match() returns Warning: preg_match() [function.preg-match]: Compilation failed: range out of order in character class at offset 13 in [script location here and line error] - second is on subject check at offset 14.
It does this on the email address check:
if (preg_match('/[^a-zA-Z0-9_-.]/', $_POST['txtEmail']))
and subject check:
if (preg_match('/[^a-zA-Z0-9:?-. ]/', $_POST['txtSubject']))
I'm not familiar with PHP but can cut and paste! My website's frowey.com and it's the comments form on contact us that's started throwing an error after hosting OS updates. Thanks in advance.
You need to escape the -
minus. It has special meaning with character classes, as the error message hints. Use a backslash before the minus:
preg_match('/[^a-zA-Z0-9_\-.]/'
(Alternatively the -
may be the first or last thing in the character group, so it loses its special function.)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With