not match by case

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
irealms
Forum Contributor
Posts: 215
Joined: Mon Apr 28, 2003 7:10 am
Location: Leeds

not match by case

Post 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?
User avatar
m3mn0n
PHP Evangelist
Posts: 3548
Joined: Tue Aug 13, 2002 3:35 pm
Location: Calgary, Canada

Post by m3mn0n »

[php_man]eregi[/php_man]()
User avatar
irealms
Forum Contributor
Posts: 215
Joined: Mon Apr 28, 2003 7:10 am
Location: Leeds

Post 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.
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post 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
User avatar
irealms
Forum Contributor
Posts: 215
Joined: Mon Apr 28, 2003 7:10 am
Location: Leeds

Post 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
User avatar
tim
DevNet Resident
Posts: 1165
Joined: Thu Feb 12, 2004 7:19 pm
Location: ohio

Post by tim »

dont bother with the other suggestions, WAY to much hassel

http://us2.php.net/manual/en/function.strcasecmp.php
Post Reply