robcrozier Posted March 7, 2007 Share Posted March 7, 2007 hi, what I'm trying to do is allow a user to enter their username and password in either upper or lower case and have it match the data in the MySQL database either way. For example they may input everything in upper case or maybe just the password in upper and the username in a mixture or upper and lower. Is there any way that this can be broken down into a simple MySQL search which would return a match no matter what case the characters are in? cheers! Quote Link to comment https://forums.phpfreaks.com/topic/41643-converting-to-upper-or-lower-case-and-use-for-mysql-search/ Share on other sites More sharing options...
c_shelswell Posted March 7, 2007 Share Posted March 7, 2007 strtoupper search the php manual for that. Should help you Quote Link to comment https://forums.phpfreaks.com/topic/41643-converting-to-upper-or-lower-case-and-use-for-mysql-search/#findComment-201773 Share on other sites More sharing options...
AV1611 Posted March 7, 2007 Share Posted March 7, 2007 Yes.... and no. Yes, if you do where `field` = '$var' you MUST match case but if you do where `field` LIKE '$var' you DON'T have to match case BUT... The password in another matter. I Assume you are encrypting passwords, either Sha1 or md5 or whatever. For that to work, the password MUST BE EXACT... If you are not encrypting, you prolly have another problem: If you enter % for the password, and are using LIKE you will allow anyone to log in. If you are using = you have the same problem with case... EDIT: Or, convert everything to uppercase Quote Link to comment https://forums.phpfreaks.com/topic/41643-converting-to-upper-or-lower-case-and-use-for-mysql-search/#findComment-201775 Share on other sites More sharing options...
robcrozier Posted March 7, 2007 Author Share Posted March 7, 2007 tbh mate i am not currently encrypting my data. How do you actually do this securely? is is a simple case of converting the usernames and passwords to md5 and then storing them in the database. when the user enters their password though and it is again encrypted before a match search is performed will this encrypted string not differ from what is stored in the database? can you explain how i should go about encrypting my data? thanks a lot! Quote Link to comment https://forums.phpfreaks.com/topic/41643-converting-to-upper-or-lower-case-and-use-for-mysql-search/#findComment-201785 Share on other sites More sharing options...
robcrozier Posted March 7, 2007 Author Share Posted March 7, 2007 its ok actually I've worked out how to do it, cheers for your help guys! Quote Link to comment https://forums.phpfreaks.com/topic/41643-converting-to-upper-or-lower-case-and-use-for-mysql-search/#findComment-201801 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.