Registration/Login Form

Theres probably lots of these questions in here, but couldnt find any like this. Im wanting to create a login and registration form, but I need the password to have at least one uppercase, one lowercase, one number, and either & or _ symbol, anyone have any ideas? I know I need to use the preg_match function but just not sure how to do it? If anyone has any full examples it would be great.

Thanks

Well, there are several ways to accomplish this task. First, you can use the “ctype” function and loop thru the letters to see if one is upper case and one is lower case. You would use a foreach loop selecting each letter and then test it with:
if (ctype_upper($letter)) {Do some code…}
Same with lower, just ctype_lower()…

So, set some variables for each of the tests. Then, create a foreach loop to go thru the letters.
Compare each with the condition test needed. If found set a variable. If not, do next test…
When for loop is done, check the variable for a “good” result…

Or, study the preg_match function for formulas. I find these confusing compared to a down and dirty PHP program… Here is a link for preg_match tutorials. Not sure if it will help, but, it once you understand setting up the pattern you need, the code for using it is only one line! Good luck…
http://www.tipsntutorials.com/tutorials/PHP/50

Sponsor our Newsletter | Privacy Policy | Terms of Service