Solved

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

Posted on 2009-07-14
3
287 Views
Last Modified: 2013-12-13
as topic (php)
0
Comment
Question by:AndyPSV
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 13

Expert Comment

by:marchent
ID: 24852457
if( preg_match('/^\w+$/',  trim($user_name) ) ){
     // process
}
0
 
LVL 9

Accepted Solution

by:
xBellox earned 500 total points
ID: 24852465
This should work:

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

Open in new window

0
 

Author Closing Comment

by:AndyPSV
ID: 31603400
thanks!
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
This article discusses how to create an extensible mechanism for linked drop downs.
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question