密码检查问题

时间:2015-08-06 04:10:58

标签: php mysql

我试图提交表单时遇到一个奇怪的问题。 这是为了更改用户密码。我遇到的问题是,当我用php检查密码以查看长度,类型等时,如果用户只用字母设置新密码,它会给我提供消息"密码必须至少6个字符长&#34 ;并且数字没有发生。如果我将支票更改为$ npass> 6它的对面,它需要字母而不是数字。 真奇怪。它就像不接受字母。有什么想法吗?

这是代码:

- (UIImage *)getThumbnailOfSize:(CGSize)size forObject:(UIBezierPath *)object
{
    // to maintain the aspect ratio, we need to compute the scale
    // factors for x and y, and then use the smaller of the two
    CGFloat xscale = size.width / object.bounds.size.width;
    CGFloat yscale = size.height / object.bounds.size.height;
    CGFloat scale = (xscale < yscale) ? xscale : yscale;

    // start a graphics context with the thumbnail size
    UIGraphicsBeginImageContext( size );
    CGContextRef context = UIGraphicsGetCurrentContext();

    // here's where we scale and translate to make the image fit
    CGContextScaleCTM( context, scale, scale );
    CGContextTranslateCTM( context, -object.bounds.origin.x, -object.bounds.origin.y );

    // draw the object and get the resulting image
    [object stroke];
    UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();

    return image;
}

这是检查php

 <input type="password" name="pass">
 <input type="password" name="npass">
 <input type="password" name="npass2">

1 个答案:

答案 0 :(得分:1)

请使用以下功能

function checkPasswordStrength($password)
{
            if(!preg_match('/[A-Z]/', $password))
                return false;  // for capital letter

            elseif(!preg_match('/[0-9]/', $password))
                return false;  // for number

            elseif(!preg_match("/[a-z]/", $password) )
                return false; // for small letter

            elseif(!preg_match("/[`!%$&^*()@#]+/", $password))
                return false; // for special character

            elseif(strlen($password) < 8)
                return false; // for password length
            else
                return true;
}