Hello Friends In Need Lil Login Validation Help
Here is My Old Code
now i want to know is that is my clean_nick verify ok ???
i used this code from gumchat
i want to do simply is make sure username and password are only A-Z 0-9 Or _-
can anybody make change to my code it allows many chars now i want A-Z 0-9 Or _- Only
I Am Building Community Site
Here is My Old Code
PHP Code:
if ($_SERVER["REQUEST_METHOD"] == "POST")
{
$nickname = isset($_POST['nick']) ? $_POST['nick'] : NULL ;
$password = isset($_POST['pass']) ? $_POST['pass'] : NULL ;
$clean_nick = preg_replace('/[^[:alnum:]]/', '', $nickname);
$clean_pass = preg_replace('/[^[:alnum:]]/', '', $password);
if (empty($nickname) or empty($password))
{
$error = '<div class="error">Wrong Nickname Or Password !</div>';
}
else if (strlen($nickname) < 3||strlen($password) < 3)
{
$error = '<div class="error">Username or Password is to short, it has to be longer than 3 chars</div>';
}
else if (strlen($clean_nick) < 3||strlen($clean_pass) < 3)
{
$error = '<div class="error">Username or Password Contains special chars. Allowed chars: A-Z, a-z, 0-9, - _ @</div>';
}
else
{
/// nothing here
}
}
i used this code from gumchat
PHP Code:
$clean_nick = preg_replace('/[^[:alnum:]]/', '', $nickname);
$clean_pass = preg_replace('/[^[:alnum:]]/', '', $password
if (strlen($clean_nick) < 3||strlen($clean_pass) < 3)
{
$error = '<div class="error">Username or Password Contains special chars. Allowed chars: A-Z, a-z, 0-9, - _ @</div>';
}
can anybody make change to my code it allows many chars now i want A-Z 0-9 Or _- Only
I Am Building Community Site
Comment