Hi gang, It’s Time to Link my game to my MySQL Database thats on my Website.
(so can store player, “Gold” “Level” “Xp” “Username” and Email.
(and to send an email of ur account details incase u forget if possible.)
All my Unity-Side C# script is done and can gather required data for the .php to work with.
thinking something simple with 3 .PHP field like:
…
-
Register.PHP (registers a new account, Username, Password, Email.)
-
Loggin.PHP: (gets username, password, finds your details returns to game.)
-
UpdatingAccount.PHP (when u get XP , Gold, LVL, Updates and overrides Database of ur account, returns information displays on screen.)
// OVERIDE that players account not store a new one.
…
If possible a way to add on return from database not before sending to database to prevent cheating.
looking for good pointers to start learning the process. (have my own website to host files)
have no Idea where to Start, (yes have looked at serverhighscores)
// Example of my C# Unity Side Script.
…
IEnumeratormyRegisterUser ()
{
WWWFormform = newWWWForm();
//matchuser…
form.AddField(“newUser”, User);
form.AddField (“newPass”, Pass);
form.AddField (“newEmail”, Email);
WWWwebRequest = newWWW(RegAccount + “RegAccount.php”, form);
//withthislinewe’llwaituntilwegetaninfoback
yieldreturnwebRequest;
if(webRequest.error != null){
Debug.Log(“Unable to Connect”);
}
else
{
Debug.Log(“Account Created you may now login”);
}
}
//…MYSQLCODE…
IEnumeratormyLoginUserPART2 (){
WWWFormform = newWWWForm();
//matchuser…
form.AddField(“User”, User); //ONLYUSEUSERTOFINDCORRECTUSERFORUSERACCOUNT…
form.AddField(“Gold”, Gold);
form.AddField(“Xp”, Xp);
form.AddField(“Lvl”, Lvl);
form.AddField (“Hash”, Hash); //stoppeoplefromhacking…
WWWwebRequest = newWWW(Refresh + “SaveScore.php”, form);
//withthislinewe’llwaituntilwegetaninfoback
yieldreturnwebRequest;
if(webRequest.error != null){
Debug.Log(“Unable to Connect”);
}
else
{
//DisplayuserAccount…
UserNameText.GetComponent().text = User.ToString();
LvlText.GetComponent().text = Lvl.ToString();
XPText.GetComponent().text = Xp.ToString();
GoldText.GetComponent().text = SpaceGold.ToString();
}
}