Jump to content

Username Validation


master82

Recommended Posts

I've been having a few problems with users signing up with usernames that contain special characters, so I have decided to 'tweek' my registration authentication script to disallow special characters.

So how would I go about validating a username input to check that it only contains letters, numbers or a mixture of both?

eg

if($_POST['username'] != [color=navy]+letters and/or numbers+[/color])
{
something
}
else
{
something else
}
Link to comment
Share on other sites

Thanks for that - came up with this, but not sure exactly how to put it into the code.

[code]
ereg("^[0-9a-zA-Z]{4,10}$", "$username")
[/code]

Would this work...

[code]
if(ereg("^[0-9a-zA-Z]{4,10}$", "$username"))
{
bla
{
else
{
bla bla
}
[/code]

Also I understand the first part, it is looking for alphnumeric characters, but what is the {4,10} part doing? is this looking at the length? (a simple guess)
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.