Page is a not externally linkable
TheMadScientist - 2:40 am on Mar 24, 2011 (gmt 0)
Uh, 0-9 is zero to nine, numerically ... You need to add the dash to the possibilities of matches:
preg_match("/^[0-9-]+/", $_POST['name']);
You also want it to be all numerical or dashes, so you should match start ^ to finish $
preg_match("/^[0-9-]+$/", $_POST['name']);
And you want it to match only if it starts with a number, so you need to eliminate the - match from the first character match
preg_match("/^[0-9][0-9-]+$/", $_POST['name']);
And keep in mind the preceding will match 9--------- which may not be desirable, so you might want to check for specific NNNN-NNNNNNNN patterns, like this, which would match 4 numbers followed by - followed by 8 numbers:
preg_match("/^[0-9]{4}-[0-9]{8}$/", $_POST['name']);
And, I'll let you have some fun with it from there...