PDA

View Full Version : [PHP] Best way of "casing"?



Calon
19-08-2008, 05:16 PM
How would I stop users registering the same name but within different casing.

I've done it on Nivade, but I don't think I'm using the best way, the way I'm usnig is changing the username (in registration) to lowercase with strtolower then echoing ucwords which changes them to uppercase, but shift key rapes.

What way is the best, or is this the only way?

Moved by lAscend (Forum Super Moderator): From Designing & Development. Please post in the correct section next time.

Johno
19-08-2008, 06:09 PM
I use mysql_num_rows and that works fine?



$checkname = mysql_query("SELECT username FROM users WHERE username='$username'");
$checkname= mysql_num_rows($checkname);
if($checkname>0){
echo 'This username is currently in use!';
Works fine and it doesn't matter if one is all in lowercase, uppercase etc? or at least it certainly works fine for me?

Sorry if this isn't what you mean!

Decode
19-08-2008, 06:16 PM
For my site I have 2 rows, 1 called username which is there username as they typed it when they signed up (case sensative) and the other is called usernameid and it is there username capitalised (use strupper()). It makes it a lot eaysier to stop duplicate usernames then. :)

Dentafrice
19-08-2008, 06:30 PM
I just do the same way Johno does, never allows duplicates.

Calon
19-08-2008, 06:40 PM
@ Dentafrice / Johnno!

I'd usually close it with the curly bracket.. if I was you then. :P

Johno
19-08-2008, 06:42 PM
Well yeah of course lol :P

Just copied it straight from something I was working on so I left out the:


} else {

But yeah :) lol

Want to hide these adverts? Register an account for free!