Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 291
  • Last Modified:

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

as topic (php)
0
AndyPSV
Asked:
AndyPSV
1 Solution
 
marchentCommented:
if( preg_match('/^\w+$/',  trim($user_name) ) ){
     // process
}
0
 
xBelloxCommented:
This should work:

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

Open in new window

0
 
AndyPSVAuthor Commented:
thanks!
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now