Advertisement
xxnorxx

Login inC#

Nov 18th, 2017
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.76 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.UI;
  5. using UnityEngine.SceneManagement;
  6.  
  7. public class Login : MonoBehaviour
  8. {
  9.  
  10.     public string inputUsername = "";
  11.     public string inputPassword = "";
  12.  
  13.     string LoginURL = "http://xxnorxx.alwaysdata.net/Login.php";
  14.  
  15.  
  16.     public Canvas main;
  17.     public Canvas register;
  18.     public Button btnReg;
  19.  
  20.     public InputField IFUsername;
  21.     public InputField IFPassword;
  22.  
  23.  
  24.  
  25.     // Use this for initialization
  26.     void Start ()
  27.     {
  28.         btnReg.image.fillAmount = 0;
  29.  
  30.     }
  31.    
  32.     // Update is called once per frame
  33.     void Update ()
  34.     {
  35.         if (loginPress)
  36.         {
  37.             StartCoroutine(LoginToDB(inputUsername, inputPassword));
  38.  
  39.             //SceneManager.LoadScene("Scene2");
  40.  
  41.             inputUsername = "";
  42.             inputPassword = "";
  43.  
  44.             loginPress = false;
  45.  
  46.            
  47. }
  48.     }
  49.  
  50.     IEnumerator LoginToDB(string username, string password)
  51.     {
  52.         WWWForm form = new WWWForm();
  53.         form.AddField("usernamePost", username);
  54.         form.AddField("passwordPost", password);
  55.  
  56.         WWW www = new WWW(LoginURL, form);
  57.         yield return www;
  58.  
  59.         Debug.Log(www.text);
  60.     }
  61.  
  62.     bool loginPress = false;
  63.  
  64.     public void btnLogin()
  65.     {
  66.         if (IFUsername.text != "" && IFPassword.text != "" && IFUsername.text != "" && IFPassword.text != "")
  67.         {
  68.             inputUsername = IFUsername.text;
  69.             inputPassword = IFPassword.text;
  70.  
  71.             IFUsername.text = "";
  72.             IFPassword.text = "";
  73.             loginPress = true;
  74.         }
  75.        
  76.     }
  77.  
  78.     public void btnRegPage()
  79.     {
  80.         main.enabled = false;
  81.         register.enabled = true;
  82.     }
  83.  
  84.  
  85. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement