31.12.2013, 20:34
Hey, i was trying to make my whole system to Whirlpool, the registration works except for the login part.
This is my dialog login:
This is my dialog login:
pawn Code:
if(dialogid == 1) //Dialog login
{
if(!response) //If they click the cancel button
{
SendClientMessage(playerid, 0xFF0000, "You must login before you spawn!"); //Sends the client a error message
Kick(playerid); // and kicks him. ( you can change it to show the player the login dialog again by uncommenting the bottem line and commenting this one.
//ShowPlayerDialog(playerid, 1, DIALOG_STYLE_PASSWORD, "Login", "This account is registered! Please log in:", "Login", "");
}
if(response) //If the player clicked login
{
if(!strlen(inputtext) || strlen(inputtext) > 68) //if the password is not 1 to 100 characters
{
SendClientMessage(playerid, 0xFF0000, "You must insert a password between 1-68 characters!"); //Sends the client a error message
ShowPlayerDialog(playerid, 1, DIALOG_STYLE_PASSWORD, "Login","Your user is registered! Please login with your password below!\n{FF0000} Please enter a password between 0 and 68 characters","Login","Cancel");
return 1;
}
new buff[129];
new Query[500];
TogglePlayerSpectating(playerid, false);
mysql_real_escape_string(inputtext, inputtext); //Here we escape the inputtext to avoid SQL injections as stated above.
mysql_real_escape_string(pInfo[playerid][Nick], pInfo[playerid][Nick]); // escapeing ^^
WP_Hash(buff, 129, inputtext);
format(Query, 500, "SELECT * FROM `playerdata` WHERE `nick` COLLATE latin1_general_cs = '%s' AND `password` = '%d'", pInfo[playerid][Nick], buff); // now here check the database if the player has given the proper password.HTTP
mysql_query(Query);
mysql_store_result();
if(mysql_num_rows() > 0) { // if the password the player provided is correct and matches the database
MySQL_Login(playerid); // we will call this function and log the player in.
} else {
//other wise this means that the password that the player
//typed was incorrect and we will resend the dialog.
ShowPlayerDialog(playerid, 1, DIALOG_STYLE_PASSWORD, "Login","Your user is registered! Please login with your password below!\n The password you typed was incorrect!","Login","Cancel"); //Shows our login dialog again.
}
mysql_free_result(); //Remember to always free a result if you stored one!
}
}