Thanks for the replies.
I don't seem to be having much luck with this.
I tried the eregi method suggested and I still have the same problem so I gave the trim() method a go and that didn't seem to work either so now I'm wondering if all the coding that goes with username is somehow stoping it from working.
Heres all the validation for the username:
if (!$_POST['username']) {
$error .= "<li>Please enter a username</li><br>";
}
else if (strlen($_POST['username'])<6 || strlen($_POST['username']) >16) {
$error .= "<li>Your username must be between 6 and 16 characters long</li><br>";
}
else if (trim($_POST['username'], 'a..zA..Z0..9_')!=0) {
$error .= "<li>Your username name should only have letters, numbers and or an underscore ( _ )</li><br>";
}
else {
// check if username is unique
$result = mysql_query("select * from $TableName where username='$username'");
if (mysql_num_rows($result)) {
$error .= "<li>Sorry, that username has already been taken, please try another</li><br>";
}
}
Am I doing something obviously wrong?
Thanks.