PHP Form Validation Regular Expression, no symbols or numbers

Posted by MrEnder on Stack Overflow See other posts from Stack Overflow or by MrEnder
Published on 2010-03-22T02:55:33Z Indexed on 2010/03/22 3:11 UTC
Read the original article Hit count: 383

Filed under:
|
|
|

Ok I am trying to get the users First Name

the form gets their name perfectly fine and posts it into a variable.

Now I am trying to do error checking

else if(!preg_match("/^[\w-]+$/", $firstNameSignup)) {
       $firstNameSignupError = "Your first name cannot contain numbers or symbols, you entered " . $firstNameSignup;
       $firstNameSignup = "";
      }

I tried the above code and it does not like me but my if statement

if(!isset($firstNameSignup) || $firstNameSignup == "") {
   $firstNameSignupError = "You must enter your first name";
  }

works fine so I know that the error is in that else if statement... most likely in my regular expression

any help??? I'm totally at a loss (really new to PHP and regular expressions)

Thanks Shelby

© Stack Overflow or respective owner

Related posts about php

Related posts about form