Advertisement
Guest User

Untitled

a guest
May 11th, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.33 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.UI;
  5.  
  6.  
  7.  
  8. public class loginAccount : MonoBehaviour {
  9.  
  10. public Text accountNameLogin;
  11. public Text passwordTxt;
  12.  
  13. public string[] user;
  14.  
  15. public string loginText;
  16.    
  17.     IEnumerator WaitForRequest(WWW serverConnection)
  18.     {
  19.         yield return serverConnection;
  20.         if(serverConnection.error == null)
  21.         {
  22.             Debug.Log("OK");
  23.         }
  24.         else Debug.Log("No Good" + serverConnection.text);
  25.  
  26.     }
  27.    
  28.  
  29. public void login()
  30.     {
  31.         string serverUrl = "http://75.112.255.94/gametest/loginUser.php";
  32.         WWW serverConn = new WWW(serverUrl);
  33.         StartCoroutine(WaitForRequest(serverConn));
  34.  
  35.         string username = accountNameLogin.text;
  36.         string password = passwordTxt.text;
  37.  
  38.         WWWForm loginForm = new WWWForm();
  39.         loginForm.AddField("usernameLoginPost", username);
  40.         loginForm.AddField("passwordLoginPost", password);
  41.  
  42.         WWW loginUser = new WWW(serverUrl, loginForm);
  43.  
  44.         string loginReturn = serverConn.text;
  45.         Debug.Log(loginReturn);
  46.  
  47.     /*  bool isValidUser = validateLogin(loginReturn);
  48.         if(isValidUser)
  49.         {
  50.             //login success
  51.         }*/
  52.  
  53.  
  54.     }
  55.  
  56.     public bool validateLogin(string loginReturn)
  57.     {
  58.         bool valid = false;
  59.         user = loginReturn.Split('|');
  60.         Debug.Log(user[0]);
  61.         Debug.Log(user[1]);
  62.         return valid;
  63.     }
  64.     // Update is called once per frame
  65.    
  66. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement