Solved

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

Posted on 2009-07-14
3
288 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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
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…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

695 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