MYSQL register/login system problem
#4

BlueG's recommended
Alright I will fix up the first phase for you:
Note that I used // where I had to fix something
PHP код:
public OnPlayerConnect(playerid)    
{
    new 
query[126], pName[MAX_PLAYER_NAME], Cache:result// added a cached variable instead of a threaded query, threaded queries are faster for me but you need to start from the basic
    
GetPlayerName(playeridpNamesizeof(pName));
    
    
mysql_format(mysqlquerysizeof(query), "SELECT `admin` FROM `accounts` WHERE `name` = '%e'"pName); // Added `` between table name and column name
// The chosen column is Admin, use any column that exist in your table just to verify
//%e sepcifier to ignore escape string, You also have to turn it to mysql_format and add the connection handler to use the %e specifier
    
result mysql_query(mysqlquery); // You must identify the connection handle, store the cache in the variable
    
    
if(cache_get_row_count()) // if there were any rows found
    
{
        
SCM(pid, -1"That username is registered!");
        
ShowPlayerDialog(playerid1DIALOG_STYLE_INPUT"Login""Please login with your password.""Login""Cancel");
    }
    else 
// No rows were found
    
{    
        
SCM(pid, -1"That username is not registered. You may use it.");
        
ShowPlayerDialog(playerid2DIALOG_STYLE_INPUT"Register""Please enter a password to register.""Register""Cancel");
    }     
    return 
1;

About LoginPlayer,
Select all from the table and store it in a Cached variable
and then simply use cache_get_field_content for strings, cache_get_field_content_int for integers and cache_get_field_content_float for floats

See more here:
https://sampwiki.blast.hk/wiki/MySQL/R33#Cache_functions

Note: You HAVE to use cache_delete(cache id); after EVERY cache usage, unless you spend memory for nothing.
Reply


Messages In This Thread
MYSQL register/login system problem - by JXF - 19.06.2016, 02:37
Re: MYSQL register/login system problem - by NeXoR - 19.06.2016, 03:00
Re: MYSQL register/login system problem - by JXF - 19.06.2016, 03:09
Re: MYSQL register/login system problem - by NeXoR - 19.06.2016, 03:59

Forum Jump:


Users browsing this thread: 1 Guest(s)