Checking for Spaces
Posted: Sun Mar 19, 2006 6:35 am
This seems like a very simple process but I am obviously doing something wrong.
I just want to check that when a user enters a username they only use set characters and no spaces
Here's the validation code I am using:
I just want to check that when a user enters a username they only use set characters and no spaces
Here's the validation code I am using:
Code: Select all
if(!preg_match('/[^a-zA-Z\_\-0-9]+$/',$username))
{
$message="Your username contains illegal characters on spaces.";
unset($username);
include 'index.php'; // Show the form again!
exit();
}