squiblo Posted July 10, 2010 Share Posted July 10, 2010 I am making a register script and I am trying to give an error for passwords that are not recommended, such as "password" or the password being the same as the username. Something like this.. if ($newpass == "password") But the problem with this is, the user might enter "paSSwOrd" and the condition will say they do not equal, so what can I do so the capitals the user inputs does not matter. Sorry if you do not understand, I find it hard to explain. Thanks Quote Link to comment https://forums.phpfreaks.com/topic/207367-capitals/ Share on other sites More sharing options...
PFMaBiSmAd Posted July 10, 2010 Share Posted July 10, 2010 http://php.net/manual/en/function.strtolower.php Quote Link to comment https://forums.phpfreaks.com/topic/207367-capitals/#findComment-1084146 Share on other sites More sharing options...
wildteen88 Posted July 10, 2010 Share Posted July 10, 2010 beaten to it You can use strtolower to compare the passwords in lowercase, eg if (strtolower($newpass) == "password") { echo $newpass . ' is not an acceptable password'; } Quote Link to comment https://forums.phpfreaks.com/topic/207367-capitals/#findComment-1084147 Share on other sites More sharing options...
AbraCadaver Posted July 10, 2010 Share Posted July 10, 2010 Also, maybe: if(strcasecmp($newpass, 'password') == 0) Quote Link to comment https://forums.phpfreaks.com/topic/207367-capitals/#findComment-1084183 Share on other sites More sharing options...
xcasio Posted July 10, 2010 Share Posted July 10, 2010 Although your question has been answered, here's a small tip: To be more efficient, use single quotes in the password variable (e.g. strtolower($newpass) == 'password'). This will not make PHP search for special characters (such as \n) or variables in the string and thus use less memory. Quote Link to comment https://forums.phpfreaks.com/topic/207367-capitals/#findComment-1084193 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.