everyone can login
#1

why does this let anyone login with any password ?

Код:
format(string, sizeof(string), "SELECT * FROM users WHERE User='%s' AND Password = MD5('%s') LIMIT 1", PlayerName, inputtext);
                new escape[140];
	            mysql_real_escape_string(inputtext,escape);
	            new Success = mysql_fetch_int();
              
	             if (Success = true)
                      {
                    // blah blah , logs in the person.
Reply
#2

You're not querying the formatted string also not storing the result and what is
pawn Код:
if ( Success = true )
supposed to do? Why not just
pawn Код:
if ( mysql_num_rows ( ) )
Reply
#3

the rest of the code is correct ?
Reply
#4

shouldn't it be double equal signs in an if statement?
pawn Код:
if ( Success == true )
Otherwise I think it's just an assignment statement within and if statement. Though my pawn is rusty, just opened SAMP up again today after a year or so.
Reply
#5

I'd say so and why escaping the string after you formatted the string? ( HINT: Escape it before you format )
Reply
#6

i had == didnt work

if ( mysql_num_rows ( ) )
doesnt work either
Reply
#7

pawn Код:
new escape [ 140 ];
                mysql_real_escape_string ( inputtext, escape );

                format ( string, sizeof ( string ), "SELECT * FROM users WHERE User='%s' AND Password = MD5('%s') LIMIT 1", PlayerName, inputtext);
                mysql_query ( string ); //If you're using BlueG's plugin.
                mysql_store_result ( );
                if ( mysql_store_result )
                {
                    mysql_free_result ( );
                    // blah blah , logs in the person.
                }
                else
                {
                    mysql_free_reuslt ( );
                    // blahblah, tells the person they failatlife.
                }
Reply
#8

still lets any password login
Reply
#9

I'm not familiar with SQL in samp at all... but try this:
pawn Код:
new escape [ 140 ];
                mysql_real_escape_string ( inputtext, escape );

                format ( string, sizeof ( string ), "SELECT * FROM users WHERE User='%s' AND Password = MD5('%s') LIMIT 1", PlayerName, inputtext);
                mysql_query ( string ); //If you're using BlueG's plugin.
                if (mysql_store_result ( ))
                {
                    mysql_free_result ( );
                    // blah blah , logs in the person.
                }
                else
                {
                    mysql_free_reuslt ( );
                    // blahblah, tells the person they failatlife.
                }
Reply
#10

@XPlatform, no and thanks for using my code.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)