Markie
Posts: 251
|
| Posted: 11/05/2008, 1:07 PM |
|
I have a login form and I have seen it's possible to log in with different forms of usernames. For example, it's possible to log in as:
username
but also as:
UserName
USERNAME
USerNAME
etc.
I don't want that, as I use CCGetUserLogin() for several items of my application and it has to be exact. I'm sorry, at the moment I don't know the English word for this, but how can I avoid the user can login with different usernames (see the example). I want the user to login as:
FirstnameFamilyname
and not:
firstnamefamilyname
I can't find an option to do this
Markie
_________________
The Netherlands, GMT+1
Tools: CCS 5.1, Windows 7, Navicat, Ultraedit
Local server: XAMPP with Apache, php and MySQL
Webserver: Windows 2008 IIS 7, php and MySQL |
 |
 |
melvyn
Posts: 333
|
| Posted: 11/05/2008, 1:19 PM |
|
In your database field, set the login field as UNIQUE. It's a click from phpmyadmin.
Also you can edit an change the function CCLoginUser() in Common.php (at the end of the file).
Tell me if you need a tip with the second method.
Melvyn
_________________
Melvyn Perez
Puro Codigo
http://purocodigo.com |
 |
 |
Gena
Posts: 591
|
| Posted: 11/05/2008, 1:25 PM |
|
Try to set "Unique Property" to Yes for that field properties in your Login record.
_________________
Gena |
 |
 |
jjrjr1
Posts: 942
|
| Posted: 11/05/2008, 1:46 PM |
|
I think you might also have to turn on Case sensitivity in your MySql database.
Just setting it to unique will mean that USERNAME and username will be the same thing if you are using a case insensitive collation.
If in the case you describe USERNAME and username can both log in as the same person then case sensitivity is the issue not uniqueness of the data.
From what you described, it seems that USERNAME is probably the same as username.
Note: If collation for your table ends in '_ci' then the table is case insensitive and both USERNAME and username will be the same. Pick a collation that ends in '_cs' for case sensitive tables.
I hope That helps
_________________
John Real - More CodeCharge Studio Support at - http://CCSElite.com |
 |
 |
melvyn
Posts: 333
|
| Posted: 11/05/2008, 2:09 PM |
|
Well, using the above methods, you fall in the risk of two users named Markie and markie (as well, they're different). So it can be confusing.
The another way (not recommended) is a modified function inside Common.php; the function is CCLoginUser()
Locate the block below, inside the function, between lines 1924 and 1939 y Common.php
$SQL = "SELECT id, permissions, password FROM users WHERE login="
. $db->ToSQL($login, ccsText) . " AND password=" . $db->ToSQL($password, ccsText);
$db->query($SQL);
$Result = $db->next_record();
if ($Result) {
CCSetSession("UserID", $db->f("id"));
CCSetSession("UserLogin", $login);
CCSetSession("GroupID", $db->f("permissions"));
}
You can modify in the way below:
// add login to the select clause, in order to retrieve the login value in the database
// and compare with the login value in the login form.
$SQL = "SELECT id, permissions, password, login FROM users WHERE login="
. $db->ToSQL($login, ccsText) . " AND password=" . $db->ToSQL($password, ccsText);
$db->query($SQL);
$Result = $db->next_record();
if ($Result) {
// Let's compare the db login and the form login, if match, login
if(strcmp($db->f("login"),$login){
CCSetSession("UserID", $db->f("id"));
CCSetSession("UserLogin", $login);
CCSetSession("GroupID", $db->f("permissions"));
}
}
This must work, you can also check the another string comparison functions at http://www.php.net/strcmp
Remember that each block you change in Common.php won't be modified by CCS when is regenerated, everything in gray is "don't touch" and become white when modified.
Let us know the results...
----------
Update
the above code fails, because strcmp() isn't in the correct way. This function must return zero when both values are equal, so the line must be changed to:
if( (strcmp($db->f("login"),$login) == 0) {
...}
_________________
Melvyn Perez
Puro Codigo
http://purocodigo.com |
 |
 |
mamboBROWN
Posts: 1713
|
| Posted: 11/05/2008, 4:02 PM |
|
Markie,
Another method you might want to consider. Is to allow the user to use an email address as the login userid and have a user/screen name which could be anything the user wants. This way you will not have to worry about CaSe SeNsItIvE login.
|
 |
 |
Markie
Posts: 251
|
| Posted: 11/06/2008, 2:20 AM |
|
Yes, my problem was case sensitivity. I didn't know that MySQL collations ending with ci where case insensitive and those ending with cs where case sensitive. Lesson learned.
Now, the collation for my table is latin1_general_ci and the collation for the mem_login field is latin1_general_cs. It works and the username has to exact, otherwise there's this error:
Login or Password is incorrect.
When I had the login field marked as UNIQUE in CCS, I got this error:
Database Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near etc.
When the login field is not marked as UNIQUE, everything works like a charm.
Thanks again guys !
_________________
The Netherlands, GMT+1
Tools: CCS 5.1, Windows 7, Navicat, Ultraedit
Local server: XAMPP with Apache, php and MySQL
Webserver: Windows 2008 IIS 7, php and MySQL |
 |
 |
jjrjr1
Posts: 942
|
| Posted: 11/06/2008, 8:06 AM |
|
That's Great Markie
With case sensitivity on user logins Markie and markie and MARKIE will all be different users and WIll not allow duplicates.
I think that is what you were trying to accomplish
Have fun and take care
_________________
John Real - More CodeCharge Studio Support at - http://CCSElite.com |
 |
 |
antman48
Posts: 7
|
| Posted: 01/15/2009, 4:19 PM |
|
just set your db field to "binary" and it will work
|
 |
 |
|