upper/lower case[solved]
Moderator: General Moderators
upper/lower case[solved]
Well I am thinking of the best/most efficient method to accomplish this.
the task: I have a script that you can sign-up for, lets say u sign-up with the username tim, all lowercase, you can sign-up with Tim and it would be considered a valid username. I dont want this, no duplicate names of anykind.
so tim, Tim, TiM, etc are all no good. Tim, Timmy, would be allowed tho
I use MySQL to store the names
I have some ideas but I would like others input on what they feel is the best method to get this done.
the task: I have a script that you can sign-up for, lets say u sign-up with the username tim, all lowercase, you can sign-up with Tim and it would be considered a valid username. I dont want this, no duplicate names of anykind.
so tim, Tim, TiM, etc are all no good. Tim, Timmy, would be allowed tho
I use MySQL to store the names
I have some ideas but I would like others input on what they feel is the best method to get this done.
Last edited by tim on Mon Aug 16, 2004 6:42 pm, edited 1 time in total.
qads that method is effective but I do want to allow users to have the choice of a upper n lowercase name.
Mark I never ever thought about going that route. So simple yet so far away for me to think of, lol.
Okay, how would you let users log-in? if they sign up with tim, the way I have it now if they type Tim and the correct password, they wont log-in, they must have every letter upper/lowercase as in the order they registered the name with.
I wish for a case-insenstive log-in, but when they do their name is in the format they signed up with, so I dont see converting them to lowercase n storing them as all the letters would have to be the same.
Sorry if I sound like a newbie, i never thought about using the field attributes as you suggested and hopefully you have another piece of good advice to save me a harsh hassel in the long run.
thank you
Mark I never ever thought about going that route. So simple yet so far away for me to think of, lol.
Okay, how would you let users log-in? if they sign up with tim, the way I have it now if they type Tim and the correct password, they wont log-in, they must have every letter upper/lowercase as in the order they registered the name with.
I wish for a case-insenstive log-in, but when they do their name is in the format they signed up with, so I dont see converting them to lowercase n storing them as all the letters would have to be the same.
Sorry if I sound like a newbie, i never thought about using the field attributes as you suggested and hopefully you have another piece of good advice to save me a harsh hassel in the long run.
thank you
That's weird as that's not default behaviour. Eg. i just created a test table with id, name columns and put 'tim' in. Then a SELECT * FROM foo WHERE name='tIm' works fine (selects the row), as does TIM, TIm etc.. You have to use the mysql BINARY keyword to make it case sensitive.if they sign up with tim, the way I have it now if they type Tim and the correct password, they wont log-in, they must have every letter upper/lowercase as in the order they registered the name with.
heres my table
this code is a snipplet of the verification:
am I being dumb and missing something here?
I made another account, used TED as the username, when i try to login with ted w/ correct password, it dont recognize the name without it being all uppercase.
Code: Select all
CREATE TABLE `users` (
`username` varchar(15) default NULL,
`admin` tinyint(1) default '0',
`password` varchar(10) default NULL,
`email` varchar(35) default NULL,
`semail` tinyint(1) default '0',
`aim` varchar(35) default NULL,
`page` varchar(30) default NULL,
`about` varchar(110) default NULL,
UNIQUE KEY `username` (`username`)
)Code: Select all
<?php
// SQL:
$sql = "SELECT * FROM users WHERE username='$username'";
$result = mysql_query($sql);
$row = mysql_fetch_array($result);
// Snipplet
elseif ($password == $row["password"] && $username == $row["username"]) {
$_SESSION['username'] = $_POST['username'];
?>I made another account, used TED as the username, when i try to login with ted w/ correct password, it dont recognize the name without it being all uppercase.
-
d3ad1ysp0rk
- Forum Donator
- Posts: 1661
- Joined: Mon Oct 20, 2003 8:31 pm
- Location: Maine, USA
Have two columns. One holds the user-formatted name, one holds the lowercase one. When they register, you make another variable with the username in lowercase, make sure it doesn't exist already, then add all the info to the db. When they login, you check against the lowercase one, just incase someones name is IAmTheNeWmeMBeR and they forget where the uppercase letters go 
BUt when you call on it to display it, use the formatted one. ie. logged in users, etc.
BUt when you call on it to display it, use the formatted one. ie. logged in users, etc.
excellent suggestion feyd. I knew there was something better
Punk, that was my method to handle it. I'm glad I wasnt the only one to think of that, but theres always something better that the big gurus know.
thanks alot for the tips people
Update- i used feyd/pickles theory, it works great. That with combo of marks tweak in my SQL table, its 100%, thanks so much
Punk, that was my method to handle it. I'm glad I wasnt the only one to think of that, but theres always something better that the big gurus know.
thanks alot for the tips people
Update- i used feyd/pickles theory, it works great. That with combo of marks tweak in my SQL table, its 100%, thanks so much