SA-MP Forums Archive
[Tutorial] Mysql Register/Login system! - 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)
+---- Forum: Tutorials (https://sampforum.blast.hk/forumdisplay.php?fid=70)
+---- Thread: [Tutorial] Mysql Register/Login system! (/showthread.php?tid=305994)

Pages: 1 2 3


Mysql Register/Login system! - FireCat - 24.12.2011

Hello all, so I'l be explaining how to make a simple/basic register system, MySQL based.
This will be just a start of, with money and score, then you can edit more you're self.

What will I need?
For this tutorial, we will be using BlueG mysql plugin,and sscanf.
[REL] MySQL Plugin R6-2 https://sampforum.blast.hk/showthread.php?tid=56564
sscanf 2.0 - Fixed for 0.3d https://sampforum.blast.hk/showthread.php?tid=120356
After you installed it all continue :b

Creating the table
So connect to your phpmyadmin, or what ever your using,
And it should look something like this:

Then click on your database, and create a new table with 3 rows (as i said, im just explaining with the money)
1 For the Username, 1for the Password and 1 for the Money
Now it should look like this:

Sorry mine is in portuese :/
So where it says field you will put Money
And change the type to Int then press save.
Now errors, or mistakes? Great! Lets continue

Scripting
So on the top of your script you should add
#include <a_mysql>

So now any where in your script except functions or stocks
(I recomend, on top of OnGameModeInit) add:
This is much better and organized, to know your database info.
pawn Код:
#define mysql_host "YourHostIp"
#define mysql_user "YourMysqlUser"
#define mysql_password "YourUserPassword"
#define mysql_database "YourDatabaseName"
And in GameModeInit add
pawn Код:
public OnGameModeInit()
{
mysql_connect(mysql_host,mysql_user,mysql_database ,mysql_password);
return 1;
}
What will this do?
So it will connect your server to the database, if it doesn't try adding still OnGameModeInit
mysql_debug(1);
And check Debug.txt in your server directory.

Now lets check if the player is registered
Add this under OnPlayerConnect, as so:

pawn Код:
public OnPlayerConnect(playerid)
{
new Query[80],pName[24],string[164];
GetPlayerName(playerid,pName,24);
format(Query,sizeof(Query),"SELECT `Username` FROM `Users` WHERE `Username` = '%s' LIMIT 1;",pName);
mysql_query(Query);
mysql_store_result();
return 1;
}
This will select and store the result, retrieved from your table.
Without this, it wouldn't check if people were registered or not.
pawn Код:
public OnPlayerConnect(playerid)
{
new Query[80],pName[24],string[164];
GetPlayerName(playerid,pName,24);
format(Query,sizeof(Query),"SELECT `Username` FROM `Users` WHERE `Username` = '%s' LIMIT 1;",pName);
mysql_query(Query);
mysql_store_result();
if(mysql_num_rows() != 0)//if number of rows is different from 0 then continue
{
format(string,sizeof(string),"Hey, %s! \nYour account is registered.\nPlease enter the password to log in!",pName);
ShowPlayerDialog(playerid,0,DIALOG_STYLE_INPUT,"Lo g in",string,"Login","");
}
else
{
format(string,sizeof(string),"Hey, %s! \nYour account is not registered. \nPlease register to continue!",pName);
ShowPlayerDialog(playerid,1,DIALOG_STYLE_INPUT,"Re gister",string,"Register","");
}
mysql_free_result();
return 1;
}
So there is checking if he's registered or not, if not then show the dialog of register, else show the login dialog.
Did you notice i added mysql_free_result();?
Why? Because we used mysql_store_result() so lets free it for less memory usage.
Then we are using mysql_num_rows() != 0 to see if there are more than 0 rows.
If so it means he is registered
Lets check the register dialog code:
pawn Код:
if(dialogid == 1)
{
if(strlen(inputtext) == 0)
{
ShowPlayerDialog(playerid,Regdialog,DIALOG_STYLE_I NPUT,"Register - Enter your password","You are about to register a new account! \nPlease choose the password"cblue" for it! \n","Register!","");
}
else
{
new EscapedText[60];
mysql_real_escape_string(inputtext, EscapedText);
format(Query,sizeof(Query),"INSERT INTO `Users` (Username,Password,Money) VALUES ('%s','%s,'0')",GetPName(playerid),EscapedText);
mysql_query(Query);
SendClientMessage(playerid,green,"You have been successfully registered!");
GivePlayerMoney(playerid,5000);
SetPlayerScore(playerid,100);
}
}
Why are we using:
mysql_real_escape_string(inputtext, EscapedText);?
So for example he can't use his password as DROP `Users`
That would delete your table Users. So with that function even if he uses that it won't delete your table.
After we are using INSERT INTO `Tablename` So in this case, it will insert the Username the password, and the money, then we are using VALUES, so it will insert in those rows, the selected values.
So in this case it will insert Username, his password, and his money
Lets try the login, so add this at the end of your script
pawn Код:
stock LoginPlayer(playerid,const password[])
{
new EscapedText[60];
mysql_real_escape_string(password, EscapedText);
format(Query,sizeof(Query),"SELECT * FROM `Users` WHERE `Username` = '%s' AND `Password` = '%s'",GetPName(playerid),EscapedText);
mysql_query(Query);
mysql_store_result();
if(mysql_num_rows() != 0)
{
SendClientMessage(playerid,green,"You have been logged in!");
LoadStats(playerid);
}
else
{
SendClientMessage(playerid,red,"Wrong password!");
Kick(playerid);
}
mysql_free_result();
return 1;
}
So as you can see we are using mysql_real_escape_string() again
And this will check if the password is correct or not. Is not kick player, else load his status.
So we are using mysql_num_rows() != 0 again, so it will select the username and his password.
If the password is wrong, it wont select the password.
Add this in the OnDialogResponse
pawn Код:
if(dialogid == Logindialog)
{
if(strlen(inputtext) == 0)
{
ShowPlayerDialog(playerid,Regdialog,DIALOG_STYLE_I NPUT,"Register - Enter your password","You are about to register a new account! \nPlease choose the password for it! \n","Register!","");
}
else
{
LoginPlayer(playerid,inputtext);
}
}
Here we are just trying to check if he inputs a password, else check if the password is correct.
So on top of OnGameModeInit add this:
pawn Код:
enum PlayerInfo
{
Username[23],
Password[24],
Money
}
new PInfo[MAX_PLAYERS][PlayerInfo]
Thats the enum for your players, where his status will be loaded.
Now lets make it load the status:
pawn Код:
stock LoadStats(playerid)
{
new pName[24],Query[80];
GetPlayerName(playerid,pName,24);
format(Query, sizeof(Query), "SELECT * FROM `Users` WHERE `Username` = '%s' ", pName);
mysql_query(Query);
mysql_store_result();
mysql_fetch_row_format(Query, "|");
sscanf(Query, "e<p<|>s[24]s[23]i>", PInfo[playerid]);
mysql_free_result();
GivePlayerMoney(playerid,PInfo[playerid][Money]);
return 1;
}
The first s is for his username, the second s is for his password, the third s is for his money.
Then below you can see we are giving his money.
So we are using mysq_fetch_row_format so it selects the selected row in sscanf, then put a |
Then it will separate each row by a | and in sscanf we are selecting 3 rows.

Any questions, or errors?
Ask'em here, ill try my best to help you, even tho im not a mysql genie :b


Re: Mysql Register/Login system! - PlayHard - 24.12.2011

It's just what I needed for God Sake TODAY'S THE BEST DAY EVERY FOR ME. Dude, thanks a lot! Merry Christmas!

pawn Код:
#define mysql_host                                              "YourHostIp"
#define mysql_user                                              "YourMysqlUser"
#define mysql_password                                          "YourUserPassword"
#define mysql_database                                          "YourDatabaseName"

Can you give an example on those?


Re: Mysql Register/Login system! - Coffeemonster - 24.12.2011

They're defined by the hosting you use to host the MySQL database, for example:

#define mysql_host "localhost"
#define mysql_user "user1"
#define mysql_password "password1"
#define mysql_database "server"


Re: Mysql Register/Login system! - PlayHard - 24.12.2011

EDIT:

pawn Код:
C:\Documents and Settings\Administrator\My Documents\Downloads\samp03dsvr_R2_win32\gamemodes\mrp.pwn(21) : error 001: expected token: ";", but found "new"
C:\Documents and Settings\Administrator\My Documents\Downloads\samp03dsvr_R2_win32\gamemodes\mrp.pwn(52) : error 017: undefined symbol "GetPName"
C:\Documents and Settings\Administrator\My Documents\Downloads\samp03dsvr_R2_win32\gamemodes\mrp.pwn(57) : error 017: undefined symbol "green"
C:\Documents and Settings\Administrator\My Documents\Downloads\samp03dsvr_R2_win32\gamemodes\mrp.pwn(62) : error 017: undefined symbol "red"
C:\Documents and Settings\Administrator\My Documents\Downloads\samp03dsvr_R2_win32\gamemodes\mrp.pwn(63) : warning 217: loose indentation
C:\Documents and Settings\Administrator\My Documents\Downloads\samp03dsvr_R2_win32\gamemodes\mrp.pwn(50) : warning 204: symbol is assigned a value that is never used: "string"
C:\Documents and Settings\Administrator\My Documents\Downloads\samp03dsvr_R2_win32\gamemodes\mrp.pwn(76) : error 017: undefined symbol "sscanf"
C:\Documents and Settings\Administrator\My Documents\Downloads\samp03dsvr_R2_win32\gamemodes\mrp.pwn(104) : error 017: undefined symbol "string"
C:\Documents and Settings\Administrator\My Documents\Downloads\samp03dsvr_R2_win32\gamemodes\mrp.pwn(104) : error 017: undefined symbol "string"
C:\Documents and Settings\Administrator\My Documents\Downloads\samp03dsvr_R2_win32\gamemodes\mrp.pwn(104) : error 029: invalid expression, assumed zero
C:\Documents and Settings\Administrator\My Documents\Downloads\samp03dsvr_R2_win32\gamemodes\mrp.pwn(104) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664          Copyright (c) 1997-2006, ITB CompuPhase


9 Errors.



Re: Mysql Register/Login system! - Kar - 24.12.2011

pawn Код:
new Query[200],pName[24];
    GetPlayerName(playerid,pName,24);
    format(Query,sizeof(Query),"SELECT `Username` = '%s' FROM `Users`",pName);
200 string length just for that? I think it can be lowered severely.


Re: Mysql Register/Login system! - PlayHard - 24.12.2011

Well,

pawn Код:
#include <a_samp>
#include <streamer>
#include <a_mysql>
#include <sscanf2>

#define mysql_host                                              "YourHostIp"
#define mysql_user                                              "YourMysqlUser"
#define mysql_password                                          "YourUserPassword"
#define mysql_database                                          "YourDatabaseName"

main()
{
    printf("Hi");
}

enum PlayerInfo
{
    Username[23],
    Password[24],
    Money
}
new PInfo[MAX_PLAYERS][PlayerInfo]

public OnGameModeInit()
{
    mysql_connect(mysql_host,mysql_user,mysql_database,mysql_password);
    SetGameModeText("Motel RP");
    CreateDynamicObject(14783,2217.31860352,-1143.14697266,1023.42614746,0.00000000,0.00000000,358.00000000); //object(int3int_kbsgarage) (1)
    CreateDynamicObject(14834,2214.42968750,-1155.06799316,1025.02209473,0.00000000,0.00000000,0.00000000); //object(lm_stripplant) (1)
    CreateDynamicObject(977,2243.01464844,-1160.77770996,1029.68249512,0.00000000,0.00000000,101.75000000); //object(newtowerdoor1) (1)
    CreateDynamicObject(977,2239.39501953,-1160.78808594,1029.68249512,0.00000000,0.00000000,101.74987793); //object(newtowerdoor1) (2)
    CreateDynamicObject(977,2239.33544922,-1171.72338867,1029.68249512,0.00000000,0.00000000,101.74987793); //object(newtowerdoor1) (3)
    CreateDynamicObject(977,2226.59301758,-1186.72668457,1030.40075684,0.00000000,0.00000000,191.74987793); //object(newtowerdoor1) (4)
    CreateDynamicObject(977,2210.59814453,-1190.60839844,1030.40075684,0.00000000,0.00000000,191.74438477); //object(newtowerdoor1) (5)
    CreateDynamicObject(977,2195.11621094,-1174.09912109,1030.30810547,0.00000000,0.00000000,101.24438477); //object(newtowerdoor1) (6)
    CreateDynamicObject(977,2195.09887695,-1158.02233887,1030.30810547,0.00000000,0.00000000,101.23901367); //object(newtowerdoor1) (7)
    CreateDynamicObject(977,2191.23999023,-1157.99169922,1030.30810547,0.00000000,0.00000000,101.23901367); //object(newtowerdoor1) (8)
    CreateDynamicObject(1723,2217.68945312,-1155.00512695,1024.79687500,0.00000000,0.00000000,180.00000000); //object(mrk_seating1) (1)
    CreateDynamicObject(1723,2219.15283203,-1152.37744141,1024.79687500,0.00000000,0.00000000,269.99450684); //object(mrk_seating1) (2)
    CreateDynamicObject(1723,2215.73437500,-1152.02197266,1024.79687500,0.00000000,0.00000000,359.98901367); //object(mrk_seating1) (3)
    CreateDynamicObject(2008,2215.69946289,-1144.85717773,1025.42248535,0.00000000,0.00000000,180.00000000); //object(officedesk1) (1)
    CreateDynamicObject(2166,2215.11059570,-1140.28161621,1025.14624023,0.00000000,0.00000000,0.00000000); //object(med_office_desk_2) (1)
    CreateDynamicObject(1670,2216.16308594,-1153.43225098,1025.35156250,0.00000000,0.00000000,0.00000000); //object(propcollecttable) (1)
    CreateDynamicObject(18028,2240.63012695,-1154.72802734,1024.30493164,0.00000000,0.00000000,90.00000000); //object(smllbarinterior) (1)
    CreateDynamicObject(14651,2241.39306641,-1163.84631348,1024.21655273,0.00000000,0.00000000,88.00000000); //object(trukstp05) (1)
    return 1;
}

stock LoginPlayer(playerid,const password[])
{
    new string[165],EscapedText[60];
    new Query[200],pName[24];
    GetPlayerName(playerid,pName,24);
    mysql_real_escape_string(password, EscapedText);
    format(Query,sizeof(Query),"SELECT * FROM `Users` WHERE `Username` = '%s' AND `Password` = '%s'",pName,EscapedText);
    mysql_query(Query);
    mysql_store_result();
    if(mysql_num_rows() != 0)
    {
        SendClientMessage(playerid,green,"You have been logged in!");
        LoadStats(playerid);
    }
    else
    {
            SendClientMessage(playerid,red,"Wrong password!");
        Kick(playerid);
    }
    mysql_free_result();
    return 1;
}
stock LoadStats(playerid)
{
    new pName[24];
    GetPlayerName(playerid,pName,24);
    format(Query, sizeof(Query), "SELECT `Username` = '%s' FROM `Users`", pName);
    mysql_query(Query);
    mysql_store_result();
    mysql_fetch_row_format(Query, "|");
    sscanf(Query, "e<p<|>s[24]s[23]i>", PInfo[playerid]);
    mysql_free_result();
    GivePlayerMoney(playerid,PInfo[playerid][Money]);
    return 1;
}

public OnGameModeExit()
{
    return 1;
}

public OnPlayerRequestClass(playerid, classid)
{
    SetPlayerPos(playerid, 1958.3783, 1343.1572, 15.3746);
    SetPlayerCameraPos(playerid, 1958.3783, 1343.1572, 15.3746);
    SetPlayerCameraLookAt(playerid, 1958.3783, 1343.1572, 15.3746);
    return 1;
}

public OnPlayerConnect(playerid)
{
    new pName[24];
    GetPlayerName(playerid,pName,24);
    format(Query,sizeof(Query),"SELECT `Username` = '%s' FROM `Users`",pName);
    mysql_query(Query);
    mysql_store_result();
    if(mysql_num_rows() != 0)//if number of rows is different from 0 then continue
    {
        format(string,sizeof(string),"Hey, %s! \nYour account is registered.\nPlease enter the password to log in!",pName);
        ShowPlayerDialog(playerid,0,DIALOG_STYLE_INPUT,"Log in",string,"Login","");
    }
    else
    {
        format(string,sizeof(string),"Hey, %s! \nYour account is not registered. \nPlease register to continue!",pName);
        ShowPlayerDialog(playerid,1,DIALOG_STYLE_INPUT,"Register",string,"Register","");
    }
    mysql_free_result();
    return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
    return 1;
}

public OnPlayerSpawn(playerid)
{
    return 1;
}

public OnPlayerDeath(playerid, killerid, reason)
{
    return 1;
}

public OnVehicleSpawn(vehicleid)
{
    return 1;
}

public OnVehicleDeath(vehicleid, killerid)
{
    return 1;
}

public OnPlayerText(playerid, text[])
{
    return 1;
}

public OnPlayerCommandText(playerid, cmdtext[])
{
    if (strcmp("/mycommand", cmdtext, true, 10) == 0)
    {
        // Do something here
        return 1;
    }
    return 0;
}

public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
    return 1;
}

public OnPlayerExitVehicle(playerid, vehicleid)
{
    return 1;
}

public OnPlayerStateChange(playerid, newstate, oldstate)
{
    return 1;
}

public OnPlayerEnterCheckpoint(playerid)
{
    return 1;
}

public OnPlayerLeaveCheckpoint(playerid)
{
    return 1;
}

public OnPlayerEnterRaceCheckpoint(playerid)
{
    return 1;
}

public OnPlayerLeaveRaceCheckpoint(playerid)
{
    return 1;
}

public OnRconCommand(cmd[])
{
    return 1;
}

public OnPlayerRequestSpawn(playerid)
{
    return 1;
}

public OnObjectMoved(objectid)
{
    return 1;
}

public OnPlayerObjectMoved(playerid, objectid)
{
    return 1;
}

public OnPlayerPickUpPickup(playerid, pickupid)
{
    return 1;
}

public OnVehicleMod(playerid, vehicleid, componentid)
{
    return 1;
}

public OnVehiclePaintjob(playerid, vehicleid, paintjobid)
{
    return 1;
}

public OnVehicleRespray(playerid, vehicleid, color1, color2)
{
    return 1;
}

public OnPlayerSelectedMenuRow(playerid, row)
{
    return 1;
}

public OnPlayerExitedMenu(playerid)
{
    return 1;
}

public OnPlayerInteriorChange(playerid, newinteriorid, oldinteriorid)
{
    return 1;
}

public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    return 1;
}

public OnRconLoginAttempt(ip[], password[], success)
{
    return 1;
}

public OnPlayerUpdate(playerid)
{
    return 1;
}

public OnPlayerStreamIn(playerid, forplayerid)
{
    return 1;
}

public OnPlayerStreamOut(playerid, forplayerid)
{
    return 1;
}

public OnVehicleStreamIn(vehicleid, forplayerid)
{
    return 1;
}

public OnVehicleStreamOut(vehicleid, forplayerid)
{
    return 1;
}


public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if(dialogid == 1)
    {
        new string[220];
        if(strlen(inputtext) == 0)
        {
            ShowPlayerDialog(playerid,Regdialog,DIALOG_STYLE_INPUT,"Register - Enter your password","You are about to register a new account! \nPlease choose the password"cblue" for it! \n","Register!","");
        }
        else
        {
            new EscapedText[60];
            mysql_real_escape_string(inputtext, EscapedText);
            format(Query,sizeof(Query),"INSERT INTO `Users` (Username,Password,Money) VALUES ('%s','%s,'0')",GetPName(playerid),EscapedText);
            mysql_query(Query);
            SendClientMessage(playerid,green,"You have been successfully registered!");
            GivePlayerMoney(playerid,5000);
            SetPlayerScore(playerid,100);
        }
    }
    if(dialogid == Logindialog)
    {
        if(strlen(inputtext) == 0)
        {
            ShowPlayerDialog(playerid,Regdialog,DIALOG_STYLE_INPUT,"Register - Enter your password","You are about to register a new account! \nPlease choose the password for it! \n","Register!","");
        }
        else
        {
            LoginPlayer(playerid,inputtext);
        }
    }
    return 1;
}

public OnPlayerClickPlayer(playerid, clickedplayerid, source)
{
    return 1;
}
Here is my script and Uhm .. The errors:

pawn Код:
C:\Documents and Settings\Administrator\My Documents\Downloads\samp03dsvr_R2_win32\gamemodes\mrp.pwn(24) : error 001: expected token: ";", but found "public"
C:\Documents and Settings\Administrator\My Documents\Downloads\samp03dsvr_R2_win32\gamemodes\mrp.pwn(60) : error 017: undefined symbol "green"
C:\Documents and Settings\Administrator\My Documents\Downloads\samp03dsvr_R2_win32\gamemodes\mrp.pwn(65) : error 017: undefined symbol "red"
C:\Documents and Settings\Administrator\My Documents\Downloads\samp03dsvr_R2_win32\gamemodes\mrp.pwn(66) : warning 217: loose indentation
C:\Documents and Settings\Administrator\My Documents\Downloads\samp03dsvr_R2_win32\gamemodes\mrp.pwn(51) : warning 204: symbol is assigned a value that is never used: "string"
C:\Documents and Settings\Administrator\My Documents\Downloads\samp03dsvr_R2_win32\gamemodes\mrp.pwn(75) : error 017: undefined symbol "Query"
C:\Documents and Settings\Administrator\My Documents\Downloads\samp03dsvr_R2_win32\gamemodes\mrp.pwn(75) : error 017: undefined symbol "Query"
C:\Documents and Settings\Administrator\My Documents\Downloads\samp03dsvr_R2_win32\gamemodes\mrp.pwn(75) : error 029: invalid expression, assumed zero
C:\Documents and Settings\Administrator\My Documents\Downloads\samp03dsvr_R2_win32\gamemodes\mrp.pwn(75) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664          Copyright (c) 1997-2006, ITB CompuPhase


7 Errors.
I can fix some errors


Re: Mysql Register/Login system! - BetaLaxx - 24.12.2011

Dude You Rocked My Day, ILOVEYOU! (as a friend :P)


Re: Mysql Register/Login system! - FireCat - 24.12.2011

Quote:
Originally Posted by Kar
Посмотреть сообщение
pawn Код:
new Query[200],pName[24];
    GetPlayerName(playerid,pName,24);
    format(Query,sizeof(Query),"SELECT `Username` = '%s' FROM `Users`",pName);
200 string length just for that? I think it can be lowered severely.
Ups my bad!


Re: Mysql Register/Login system! - [HiC]TheKiller - 24.12.2011

I never knew that you could use a where clause in the selection for the column name. Maybe I learnt something new?


Re: Mysql Register/Login system! - FireCat - 24.12.2011

Quote:
Originally Posted by [HiC]TheKiller
Посмотреть сообщение
I never knew that you could use a where clause in the selection for the column name. Maybe I learnt something new?
What do you mean?


Re: Mysql Register/Login system! - [HiC]TheKiller - 24.12.2011

Code:
SELECT ColumnName FROM TableName WHERE ColumnName = value
Also

Code:
SELECT columns, ... FROM tablename WHERE something = some value
I've never heard of it being

Code:
SELECT column = some value FROM tablename



Re: Mysql Register/Login system! - Gazmull - 25.12.2011

?
pawn Code:
format(Query,sizeof(Query),"SELECT `Username` = '%s' FROM `Users` LIMIT 1;",pName);
should it be like this one?
pawn Code:
format(Query,sizeof(Query),"SELECT * FROM `Users` WHERE `Username` = '%s'",pName);
or is it really like that?


Re: Mysql Register/Login system! - #marcus. - 25.12.2011

I think he is just getting name so the script knows if the player is registered or not, if it is, then the loading data comes, know what I mean?


OFF: Merry Christmas guys


Re: Mysql Register/Login system! - Niko_boy - 26.12.2011

hmmmmmmmmmmm
Quote:

public OnPlayerConnect(playerid)
{
new Query[80],pName[24];
GetPlayerName(playerid,pName,24);
format(Query,sizeof(Query),"SELECT FROM `Users` WHERE `Username` = '%s' LIMIT 1;",pName);
mysql_query(Query);
mysql_store_result();
return 1;
}

You Missed something
U using string there in format and sending dialog , but u havent defined string
so new string[128]; after line new Query[80],pName[24];
or as new Query[80],pName[24] , string[128];
:P
I mentioned this cause some new ppl will get confused/o:

[]_[]
____
still nice tutorial


Re: Mysql Register/Login system! - =WoR=G4M3Ov3r - 27.12.2011

Quote:
Originally Posted by Jagat
View Post
hmmmmmmmmmmm

You Missed something
U using string there in format and sending dialog , but u havent defined string
so new string[128]; after line new Query[80],pName[24];
or as new Query[80],pName[24] , string[128];
:P
I mentioned this cause some new ppl will get confused/o:

[]_[]
____
still nice tutorial
Wow you're smart.

He's using Query as a String.


Re: Mysql Register/Login system! - [HiC]TheKiller - 27.12.2011

pawn Code:
format(Query,sizeof(Query),"SELECT FROM `Users` WHERE `Username` = '%s' LIMIT 1;",pName);
You're not actually selecting anything, this may cause issues. What you should do is

pawn Code:
format(Query,sizeof(Query),"SELECT `Username` FROM `Users` WHERE `Username` = '%s' LIMIT 1",pName);



Re: Mysql Register/Login system! - FireCat - 27.12.2011

Quote:
Originally Posted by [HiC]TheKiller
View Post
pawn Code:
format(Query,sizeof(Query),"SELECT FROM `Users` WHERE `Username` = '%s' LIMIT 1;",pName);
You're not actually selecting anything, this may cause issues. What you should do is

pawn Code:
format(Query,sizeof(Query),"SELECT `Username` FROM `Users` WHERE `Username` = '%s' LIMIT 1",pName);
Thanks asian ^^


Re: Mysql Register/Login system! - HyperZ - 27.12.2011

Nice Tutorial .


Re: Mysql Register/Login system! - FireCat - 27.12.2011

Quote:
Originally Posted by HyperZ
View Post
Nice Tutorial .
thanks


Re: Mysql Register/Login system! - suhrab_mujeeb - 27.12.2011

Nice tutorial, cat.