Connecting To PHP / MYSQL Most Simple PHP scripting...

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:

  1. Register.PHP (registers a new account, Username, Password, Email.)

  2. Loggin.PHP: (gets username, password, finds your details returns to game.)

  3. 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();

}
}

You can’t send a user’s unencrypted password to a php script, even if the host has an SSL certificate. Also, remember that any call to a php script can be done any number of ways, other than from your game. If you can call it, so can everyone else.

I realise security will be a hurdle to overcome, been looking at basic post and call and then add extra stuff (just want to make it work at the moment) using md5 huskies and stuff

been working on something like this :

PHP (RegisterUser) (hope I’m doing this the right way…

<?php // (withxamppit's "localhost"), nextisthelogin ("name" and "password"). //iftheconnectioncannotbeestablishedwegetanerrormessage, thatwe'veenteredafter "ordie" $sql_connect = mysql_connect("localhost", "root", "") ordie ("no DB Connection"); mysql_select_db("MyGameDatabase") ordie ("DB not found"); //postnewaccount username, Password, Email... $User = $_POST['newUser']; $Pass = $_POST['newPass']; $Email = $_POST['newEmail']; mysql_query("(User, Pass, Email) VALUES ($user,$pass,$email);"); //insertnewAccount, username, password, emailassosiatedwithaccount... mysql_close($sql_connect); ?>

hope I’m on the right track… then i play not make a LoginPHP that checks the username and account ented at logging with the one stored in the database.

Read your job offer and I’d like to help out but you cannot be contacted by message on this board. Send me a PM if you need help.

Hi zak666, I have read your last post as well but the post is closed to communication and you can not get PM. Send me a PM and I have a working chat solution of mine that I can change it for your needs. Thanks

your going about this in a very overcomplicated way i can get a system up and running for you in an hour or less i read your job offer if you decide you want the help send me en email deathcrow4561@gmail.com