Forum Moderators: coopster
I have a text field containing a phone number that needs to be tested against a pattern
The form number is of the form (0032)499/78 98 34 and the pattern i designed looks like this:
if(array_key_exists('submit', $_POST))
{
// check phone number
$phone=trim($_POST['phone']);
if(!preg_match('/^([0-9]{4})[0-9]{3}/[0-9]{2}\h[0-9]{2}\h[0-9]{2}$/', $phone))
{
echo "Phone number does not appear to be valid";
include('../mysql_queries/display_form.inc.php');
exit();
}
When that script is run I get an error of the form:
Warning: preg_match() [function.preg-match]: Unknown modifier '[' in C:\htdocs\MySQL_queries\changephone.php on line 14
Does this phone number match the pattern?
Can you please tell me what's wrong with this code?
regards,
It's echoeing: "Phone number does not seem valid". I am confused at this point cause i thought the number matched the pattern that way. Any idea why this?