Good day to all, i have a problem, i have made a login with mysql remote connection. when im trying to login i cant login. i dont know how to use the GUI.TextArea exactly. here is my code:
void OnGUI()
{
GUI.Box(new Rect(Screen.width/2-60,Screen.height/2-105,120,210),"Score");
firstName = GUI.TextArea(new Rect(Screen.width/2-45,Screen.height/2-80,90,20),firstName);
Password = GUI.TextArea(new Rect(Screen.width/2-45,Screen.height/2-50,90,20),Password);
if(GUI.Button(new Rect(Screen.width/2-45,Screen.height/2-20,90,20),"Continue"))
{
SelectDatabase(firstName,Password);
}
if(GUI.Button(new Rect(Screen.width/2-50,Screen.height/2+70,100,20),"Back to Menu"))
{
Application.LoadLevel("mainMenu");
}
}
public void SelectDatabase(string username, string password)
{
connectionstring = @"Server=db4free.net; Port=3306; Database=gladia***; Uid=der****; Password=*********;";
conn = new MySqlConnection(connectionstring);
da = new MySqlDataAdapter();
ds = new DataSet();
try
{
da.SelectCommand = conn.CreateCommand();
da.SelectCommand.CommandText = "select * from users where username=@username and password=@password";
da.SelectCommand.CommandType = CommandType.Text;
da.SelectCommand.Parameters.Add("@username",MySqlDbType.Text,15,"username").Value = username;
da.SelectCommand.Parameters.Add("@password",MySqlDbType.Text,15,"password").Value = password;
da.Fill(ds,"users");
if (ds.Tables["users"].Rows.Count == 1)
{
Debug.Log("pasok!");
}
else
{
Debug.Log("Wrong username and Password");
}
}
catch (System.Exception ex)
{
Debug.Log(ex.Message);
}
}
if i change the @username to a correct username and @password to correct password im successfully login. what may be the possible reason why Debug.Log(“Wrong username and Password”); always prompting? i think the problem is in firstName and Password variables but i dont know how to fix it. thank you in advance.