Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.UI;
- using UnityEngine.SceneManagement;
- public class Login : MonoBehaviour
- {
- public string inputUsername = "";
- public string inputPassword = "";
- string LoginURL = "http://xxnorxx.alwaysdata.net/Login.php";
- public Canvas main;
- public Canvas register;
- public Button btnReg;
- public InputField IFUsername;
- public InputField IFPassword;
- // Use this for initialization
- void Start ()
- {
- btnReg.image.fillAmount = 0;
- }
- // Update is called once per frame
- void Update ()
- {
- if (loginPress)
- {
- StartCoroutine(LoginToDB(inputUsername, inputPassword));
- //SceneManager.LoadScene("Scene2");
- inputUsername = "";
- inputPassword = "";
- loginPress = false;
- }
- }
- IEnumerator LoginToDB(string username, string password)
- {
- WWWForm form = new WWWForm();
- form.AddField("usernamePost", username);
- form.AddField("passwordPost", password);
- WWW www = new WWW(LoginURL, form);
- yield return www;
- Debug.Log(www.text);
- }
- bool loginPress = false;
- public void btnLogin()
- {
- if (IFUsername.text != "" && IFPassword.text != "" && IFUsername.text != "" && IFPassword.text != "")
- {
- inputUsername = IFUsername.text;
- inputPassword = IFPassword.text;
- IFUsername.text = "";
- IFPassword.text = "";
- loginPress = true;
- }
- }
- public void btnRegPage()
- {
- main.enabled = false;
- register.enabled = true;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement