Yeah I agree with John, ereg & eregi have been deprecated since PHP 5.0.3
so you should use preg_match instead for compatability sake.
Something like below(password must be min 4 to max 9 characters, change to suit);
PHP Code:
function checkPassword($value){
return preg_match('/^[- a-z0-9,<>@()&\%$#!~`]{4,9}$/i', $value) ? $value : false;
}
$pass1 = checkPassword(trim($_POST['password1']));
$pass2 = trim($_POST['password2']);
if($pass1){
if($pass1 === $pass2){
echo 'Passwords match';
}
else{
echo 'Passwords donot match';
}
}
else{
echo 'Invalid characters in password etc...';
}
I haven't included all the special characters as I cannot see much point of checking if you are going to allow all characters? but you could easily modify this to suit yourself, just be careful with brackets []{} you will need to escape these with a backslash.
Bookmarks