using UnityEngine;
using UnityEngine.UI;
using System.Collections;

public class SaveScore : MonoBehaviour 
{
	string playerNname;
	int score;

	// Use this for initialization
	void Start () {
		gameObject.GetComponent<InputField>().onEndEdit.AddListener(saveScore);
		score = 1000;

	
	}
	
	// Update is called once per frame
	void Update () {
	
	}
	void saveScore(string textInField)
	{
		playerNname = textInField;
		print ("Starting to save score for user "+textInField);
		StartCoroutine(connectToPHP());

	}

	IEnumerator connectToPHP() 
	{
		string url = "http://localhost:8888/updateScore_b.php";
		url += "?name=" + playerNname + "&score=" + score; 
		WWW www = new WWW(url);
		yield return www;
		print ("DB updated");
	}


}
