Page 1 of 1
not match by case
Posted: Mon Oct 11, 2004 3:41 am
by irealms
Is there a way to make an if statement not need an exact match between 2 fields?
so for example when checking "Test" and "test" it would say that they were the same and not treat them as not matching?
Posted: Mon Oct 11, 2004 3:45 am
by m3mn0n
[php_man]eregi[/php_man]()
Posted: Mon Oct 11, 2004 3:56 am
by irealms
thanks, i can see how that detects cahracters but i need something different i think.
I have a session variable set from a username when a user logs on.
For security it is checked against a username held in a database on some pages.
The problem is, if the user enters "Test" to logon and "test" is in the database a loop comparing the 2 doesn't think they match due to the capitol.
Posted: Mon Oct 11, 2004 5:19 am
by twigletmac
If your usernames aren't case sensitive, you could enter them in lower case in the db and then just use [php_man]strtolower[/php_man]() to convert whatever the user enters to the same case.
Mac
Posted: Thu Oct 14, 2004 3:09 am
by irealms
yeah thanks for that, i think i'll just make sure that when the user registers and logs on it's converted to lowercase. Will write a quick query to alter all the ones in the database to lowercase too.
Thanks again
Posted: Thu Oct 14, 2004 4:17 pm
by tim
dont bother with the other suggestions, WAY to much hassel
http://us2.php.net/manual/en/function.strcasecmp.php