Hello,
I'm trying to make a register system using mysql. I got some problems while creating the account and saving it to mysql.
Here's my code:
PHP Code:
registeraccount(username, password)
{
args = [];
args[0] = "register";
maps\mp\gametypes\_mysql::asyncQuery("SELECT createNewAccount('" + maps\mp\gametypes\_mysql::stripstring(username) + "', '" + maps\mp\gametypes\_mysql::stripstring(password) + "') AS `userid`", ::recievelogin, args);
}
PHP Code:
recievelogin(rows, args)
{
if(rows.size && isdefined(rows[0]) && isdefined(rows[0]["userid"]) && int(rows[0]["userid"]) != 0)
{
self.pers["userid"] = int(rows[0]["userid"]);
if(isdefined(rows[0]["rank"]))
{
self.pers["admin"] = int(rows[0]["rank"]);
self thread tellmessage(sprintf(self.pers["admname"] + " Account opened ! Rank : ^1(^7%^1)", self.pers["admin"]));
return;
}
else
{
self.pers["admin"] = 0;
self.pers["admname"] = "";
return;
}
if(args[0] == "register")
self thread tellmessage("Account created !");
self thread tellmessage("In case you forgot them, you will find a screehshot Info.jpeg on UdSSR mod folder");
self execclientcommand("screenshotJpeg Info");
return;
}
else
{
if(args[0] == "login")
self thread tellmessage("Wrong Password. Which means username is taken !");
else
self thread tellmessage("Username already exists");
}
}
PHP Code:
case "register":
if(args[2].size >= 3 && args[2].size <= 20)
{
if(args[3].size >= 5 && args[3].size <= 25)
{
registeraccount(args[2], args[3]);
return;
}
self thread tellmessage("pw too short/long");
return;
}
self thread tellmessage("user too short/long");
When i try to !register user pass i get this in console:
PHP Code:
query: SELECT createNewAccount('user', 'pass') AS `userid`
But nothing is saved to the database.
I think my createNewAccount table settings are wrong.
Any solutions please?
Thanks