Current location: Hot Scripts Forums » Programming Languages » PHP » universal login name


universal login name

Reply
  #1 (permalink)  
Old 01-30-12, 05:36 AM
dsflyerds dsflyerds is offline
New Member
 
Join Date: Oct 2011
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
universal login name

I'm working on a log in page for my website and i was wondering if there Is a way to make the username part work for both upper and lower case, for example if my username were robert if you entered Robert or ROBERT it would work as well?
Reply With Quote
  #2 (permalink)  
Old 02-06-12, 03:34 AM
Nico's Avatar
Nico Nico is offline
Community Leader
 
Join Date: Sep 2005
Location: Spain
Posts: 8,075
Thanks: 11
Thanked 88 Times in 83 Posts
Yes, there is a way.

But it's hard to tell how without knowing what you're doing. Could you post your code?
Reply With Quote
  #3 (permalink)  
Old 02-06-12, 05:56 AM
alxkls alxkls is offline
Newbie Coder
 
Join Date: Nov 2011
Posts: 98
Thanks: 0
Thanked 9 Times in 9 Posts
when inserting a user into the database you could do something like
Code:
$sql="insert into my_users_table (user_field, whatever, whatever) values ('".strtolower($_POST['some_user'])."', 'whatever', 'whatever')";
and each time you are making a query-use strtolower.
Reply With Quote
  #4 (permalink)  
Old 02-07-12, 10:35 AM
Nico's Avatar
Nico Nico is offline
Community Leader
 
Join Date: Sep 2005
Location: Spain
Posts: 8,075
Thanks: 11
Thanked 88 Times in 83 Posts
No, that's actually not necessary.

SELECT queries are case-insensitive, so it doesn't matter if the stored names are in lower or upper case when you fetch the name from the database.

Plus, some users might prefer to have capital letters in their monickers.

I suspect that the OP is actually authenticating their users without MySQL, that's why I asked for the code. The user data could be stored in an array, or in a flat file, etc...
Reply With Quote
  #5 (permalink)  
Old 02-08-12, 04:23 AM
alxkls alxkls is offline
Newbie Coder
 
Join Date: Nov 2011
Posts: 98
Thanks: 0
Thanked 9 Times in 9 Posts
Incorrect! The queries you use might be case-insensitive but that is not always the case depending on your encoding and alphabet/symbols you are using. Take the cyrillic alphabet for example:
Code:
ч, ш, щ, я, ю
or in queens english-the letters that do not have a latin equivallent. actually the first time i encountered this was last year and it took me quite a while to work it out... And as far as I remember from my days(years rather) in spain-there was a similar problem with letters such as
Code:
á, é, í, ó, ú, ñ
Still-im not sure cause as i said-thats as far as i remember. Still surely thats far not the end of it.

That is of course if he is using any type of database. if he is storing those values in some array-thats a whole different story.

Last edited by alxkls; 02-08-12 at 04:35 AM.
Reply With Quote
  #6 (permalink)  
Old 02-08-12, 07:13 AM
Host.co.in Host.co.in is offline
Newbie Coder
 
Join Date: Dec 2010
Posts: 6
Thanks: 2
Thanked 0 Times in 0 Posts
IMO it's all about the data fetched from the log in text-box and while making comparison with the data stored in the database should be kept case sensitive or not. One need to think in that direction only.
Reply With Quote
  #7 (permalink)  
Old 02-09-12, 09:54 AM
Nico's Avatar
Nico Nico is offline
Community Leader
 
Join Date: Sep 2005
Location: Spain
Posts: 8,075
Thanks: 11
Thanked 88 Times in 83 Posts
Quote:
Originally Posted by alxkls View Post
Incorrect! The queries you use might be case-insensitive but that is not always the case depending on your encoding and alphabet/symbols you are using.
Well, strtolower() won't convert those either.
Reply With Quote
  #8 (permalink)  
Old 02-09-12, 10:00 AM
alxkls alxkls is offline
Newbie Coder
 
Join Date: Nov 2011
Posts: 98
Thanks: 0
Thanked 9 Times in 9 Posts
true... forgot about that... my solution in this case was
Code:
function cyrtolower($str) {
	return strtr($str,
	"ABCDEFGHIJKLMNOPQRSTUVWXYZ".
	"АБВГДЕЖЗИЙКЛОМНОПРСТУФХЦЧШЩЬЪЮЯЭЫ",
	"abcdefghijklmnopqrstuvwxyz".
	"абвгдежзийкломнопрстуфхцчшщьъюяэы");
}
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
PHP login problem kaceykeleher PHP 5 03-13-09 11:23 AM
Help Needed Urgently with JS Login Script! semendemon JavaScript 5 11-25-07 11:24 AM
login, roles problem dbrook007 ASP.NET 10 11-10-06 03:42 PM
Login Script v1.9 Problem SuavyDoodle JavaScript 8 09-28-06 09:13 PM


All times are GMT -5. The time now is 09:02 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.