SA-MP Forums Archive
MySQL login/register problem - Case Sensitive. - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: MySQL login/register problem - Case Sensitive. (/showthread.php?tid=460821)



MySQL login/register problem - Case Sensitive. - Slepur - 30.08.2013

Hey,

I'm currently having problems with my registration system and it's quite major... Say a player has the name "John", someone can sign up under "john" and it allows them both to have the same name... Now I've been messing around with the collation of the database along with the query and I can't seem to get it fixed.

My current query to check if they're already registered:
Код:
format(Query, 500, "SELECT * FROM `playerdata` WHERE `username` COLLATE latin1_general_cs = '%s' AND `password` = md5('%s')", pInfo[playerid][User], inputtext); 
            mysql_query(Query);
            mysql_store_result();
            if(mysql_num_rows() > 0)



Re: MySQL login/register problem - Case Sensitive. - Skribblez - 30.08.2013

I think you're looking for strcmp which is it's third parameter.
Код:
(const string1[], const string2[], bool:ignorecase, length)

ignorecase (optional) - When set to true, the case doesn't matter - HeLLo is the same as Hello. When false, they're not the same.



Re: MySQL login/register problem - Case Sensitive. - Slepur - 30.08.2013

Doesn't seem to work.


Re: MySQL login/register problem - Case Sensitive. - Skribblez - 30.08.2013

Here's an example:
pawn Код:
if(!strcmp("word", "Word", false)) // This would return FALSE since it's case sensitive)
And if you change it to true:
pawn Код:
if(!strcmp("word", "Word", true)) // Returns words matches (case ignored)



Re: MySQL login/register problem - Case Sensitive. - doreto - 30.08.2013

Have you try using BINARY?

pawn Код:
format(Query, 500, "SELECT * FROM `playerdata` WHERE BINARY `username` = '%s' AND `password` = md5('%s')", pInfo[playerid][User], inputtext);
I will suggest you use more strong hash method then md5


Re: MySQL login/register problem - Case Sensitive. - Lorenc_ - 30.08.2013

Quote:
Originally Posted by doreto
Посмотреть сообщение
Have you try using BINARY?

pawn Код:
format(Query, 500, "SELECT * FROM `playerdata` WHERE BINARY `username` = '%s' AND `password` = md5('%s')", pInfo[playerid][User], inputtext);
I will suggest you use more strong hash method then md5
Or... None?

pawn Код:
SELECT * FROM `playerdata` WHERE `username` = '%s' AND `password` = md5('%s')