7 Replies - 467 Views - Last Post: 13 July 2013 - 12:57 PMRate Topic:

Change password empty field

Posted 13 July 2013 - 04:38 AM

Hello, I have successfully created my user password change script and I want the new password not be empty. Now I enter my currrent password and I set the new password to empty, and the password will be changed to empty. I want the new password not to be empty. How can I do that? I tried but nothing...

doesn't exclude empty values is that you have already used SHA1() which, even on an empty string, produces a value.

BTWW Suppressing errors with @ is considered a poor practice.

Thankks, it worked! I worked on it some and I fixed some problems. Now I have a another problem that the strlen is not working. For example I said if the strlen of the password is longer that 6 then change the password. But if the user add 1 character for his password the query will work and his password will be changed! Any ideas?

Re: Change password empty field

You need to examine your logic in this statement (or whatever you have changed it to), being aware of the order of precedence. In particular, && has higher precedence that ||. Use brackets to over-rule the precedence order.

You won't need to check the length of the old password, as it has already been checked against the value in the database, which would only have been accepted if it were more than 6 characters (once you've got the logic sorted).

If you've changed your code so that it won't accept empty passwords, then this statement should reduce to: