How to allow in login only 0-9, a-z, A-Z, _ signs ONLY?

as topic (php)
AndyPSVAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
xBelloxConnect With a Mentor Commented:
This should work:

if( preg_match( "/^[A-Za-z0-9_]+$/", $login ) ) {
    echo "Login ok";
} else {
    echo "Bad login";
}

Open in new window

0
 
marchentCommented:
if( preg_match('/^\w+$/',  trim($user_name) ) ){
     // process
}
0
 
AndyPSVAuthor Commented:
thanks!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.