Solved

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

Posted on 2009-07-14
3
284 Views
Last Modified: 2013-12-13
as topic (php)
0
Comment
Question by:AndyPSV
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Javascript Hashmap output 8 46
How to loop through records  using SELET COUNT 2 14
PHP: concatenate query 12 38
mysql between clause 2 0
Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

911 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now