This is an old revision of the document!
PasswordChange.cs
Full Script
using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.Networking; using TMPro; public class PasswordChange : MonoBehaviour { public TMP_InputField current_password; public TMP_InputField new_password; public TMP_InputField new_password_confirm; public TextMeshProUGUI username; public PopUpSystem popUp; public void ButtonChangePassword() { if (new_password.text != new_password_confirm.text) { popUp.OpenPopUp("ERROR!", "new password didn't match"); return; } if (new_password.text.Length <= 6) { popUp.OpenPopUp("ERROR!", "Field cannot be empty"); } if (current_password.text == "" || new_password.text == "" || new_password_confirm.text == "") { popUp.OpenPopUp("ERROR!", "Field cannot be empty"); return; } StartCoroutine(Upload()); } IEnumerator Upload() { WWWForm form = new WWWForm(); form.AddField("playerUsername", username.text); form.AddField("currentPassword", current_password.text); form.AddField("newPassword", new_password.text); using (UnityWebRequest www = UnityWebRequest.Post("https://puov2.gementar.com/unity_database/ChangePassword.php", form)) { yield return www.SendWebRequest(); if (www.result != UnityWebRequest.Result.Success) { Debug.Log(www.error); } else { if(www.downloadHandler.text.Equals("Password Changed.")) { popUp.OpenPopUp("ERROR!", "Password Changed."); } if (www.downloadHandler.text.Equals("Wrong Current Password Entered.")) { popUp.OpenPopUp("ERROR!", "Wrong Current Password Entered."); } if (www.downloadHandler.text.Equals("Error! Please if you find the message contact us at admin@gementar.com")) { popUp.OpenPopUp("ERROR!", "Error! Please if you find the message contact us at admin@gementar.com"); } Debug.Log(www.downloadHandler.text); } } } }
public void ButtonChangePassword()
Client side password checker.
IEnumerator Upload()
Upload password into database and check error.