The code I have written below is supposed to stop people registering with non alpha or alphanumeric names/usernames. In time I will refine it to be more strict but for now it would be good just to get it off the gorund!
As I see it, this should work but I am still able to enter usernames such as ,,,,,,, or ....... or any other character that it is supposed to disallow.
Where exactly have I gone wrong?
foreach ($HTTP_POST_VARS as $key => $value)
{
if ($key == "username" or $key =="password" or $key =="firstname" or $key =="lastname")
{
if ($value == "")
{
$blank_array[$key] ="blank";
}
}
if ($key == "username" or $key =="firstname" or $key =="lastname" or $key =="address1" or $key =="address2" or $key =="county" or $key =="postcode" or $key =="country")
{
if (!ereg("[A-Za-z' -]{1,40}",$key))
{
$bad_format[$key] ="bad";
}
}
}