View Full Version : Validation Doubts in Change password code

01-29-2007, 10:53 AM
I posted some queries earlier.Thankx all those who answered and helped me.
Here i have a doubt in my code for changing password.

Anyone please show my how to write 'if' condition for keeping the password to a limited number of characters.According to my code,it only checks whether the password fields(old,new,confirm) are empty and if not it proceeds with database comparison and if exists it get changed with the new password.

The script i am using for checking blank entry is:

echo "Username is empty";

I want it to be checked that every password should be minimum 4 characters and maximum 8 character in length and atleast one special character should be present
(like @,!,~,$,%,etc).

Please provide me other such conditional scripts in PHP for checking numeric fields for pincode,phone no etc and characters for name,username etc and I want DOB to be entered as eg:-"27 Mar" etc.

Please provide me those scripts:
(i am not asking for javascripts.plz dont mis-understand)

01-29-2007, 11:19 AM
Have a look into these functions.

strlen() (http://us2.php.net/manual/en/function.strlen.php)
stripos() (http://us2.php.net/manual/en/function.stripos.php)

You could add an additional if statement in there to check the string length then if its an appropiate length. You can then check for the special character. Using something like stripos. Depending on what you deem acceptable as a special character you might have to define an array or something w/ allowable special characters.