php - Should I use regex for registration/login forms? -
is enough use mysql_real_escape_string , strip_tags username/password inputs or should include regex? website uses deprecated mysql.
for example:
if (!preg_match( "/^[\w-\.]+@([\w-]+\.)+[\w-]{0,3}$/",$_post['email'])) { $error = "invalid email or password";
it's better validate email(inputs) before pass data mysql, fortunately, don't have use regex
email validation, php have built-in function filter_var validation. faster regex validation.
syntax be:
if(! filter_var($_post['email'], filter_validate_email)) { //email not valid, $error = "invalid email or password"; }
Comments
Post a Comment