private void login_submit_Click(object sender, EventArgs e) { //Intermediate_Error obj = new Intermediate_Error(); /* variable "passVar" is storing "login_password" Text value on clicking "Submit" button * then it is changing the value of "showPass" label so that current value of * password is displayed in label. * * "login.pass.Text" is fetching the value of password field and storing it in "passVar" variable. */ string loginUrl = "https://dmitra.000webhostapp.com/registration/registration/index.php"; string userPassword = login_password.Text; string userName = login_user.Text; using (var wb = new WebClient()) { var data = new NameValueCollection(); data["user_name"] = userName; data["user_password"] = userPassword; data["login"] = "******"; var response = wb.UploadValues(loginUrl, "POST", data); var webPageResponse = Encoding.ASCII.GetString(response); //resultShow.Text += "This is the data" + data + "\n"; //resultShow.Text += Encoding.ASCII.GetString(response); dynamic obj2 = JsonConvert.DeserializeObject(webPageResponse); int errCode = obj2.error_code; string message = obj2.message; if (errCode == 0) { // Code 0 : Successfully Logged In // Move the user to NEXT page PayBills pay_Obj = new PayBills(userName, userPassword); this.Visible = false; pay_Obj.Show(); } else if (errCode == 1) { // Code 1 : Login Failed. MessageBox.Show("Please check your login credentials again.", "Wrong Username Or Password", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
private void verifySubmit_Click(object sender, EventArgs e) { try { string registerUrl = "https://dmitra.000webhostapp.com/registration/registration/register.php"; using (var wb = new WebClient()) { var data = new NameValueCollection(); data["user_name"] = verifyUserName.Text; data["user_email"] = verifyEmail.Text; data["user_password_new"] = _password; data["user_password_repeat"] = _password; data["register"] = "Register"; data["Name"] = verifyFname.Text; data["BMSID"] = verifyBmsId.Text; data["AdharID"] = verifyAdhar.Text; data["PhoneNumber"] = verifyPhone.Text; data["BankAccount"] = bankAccountNumber; data["KNo"] = kNumber; var response = wb.UploadValues(registerUrl, "POST", data); Console.WriteLine("This is the shitnit : " + response); //MessageBox.Show(response, "JSON Reply", MessageBoxButtons.OK, MessageBoxIcon.Error); //string result = System.Text.Encoding.UTF8.GetString(response); //Console.WriteLine("This is something amazhing : " + result); var webPageResponse = Encoding.ASCII.GetString(response); //resultShow.Text += "This is the data" + data + "\n"; //resultShow.Text += Encoding.ASCII.GetString(response); //richTextBox1.Text += webPageResponse; dynamic obj2 = JsonConvert.DeserializeObject(webPageResponse); //richTextBox1.Text += "This is the JSON : \n" + obj2; int errCode = obj2.error_code; string message = obj2.message; if (errCode == 0) { // Code 0 : Successfully Signed Up // Move the user to NEXT page //MessageBox.Show("You have registered", "Succesfful", MessageBoxButtons.OK, MessageBoxIcon.Error); AutoClosingMessageBox.Show("You have registered successfully. Please wait while we redirect you...", "Succesffully Registered", 1000); PayBills pay_Obj = new PayBills(verifyUserName.Text, _password); this.Visible = false; pay_Obj.Show(); } else if (errCode == 1) { // Code 1 : Registration Failed. MessageBox.Show("Registration failed. Please try again after some time.", "Something Broke\n पंजीकरण विफल। कृपया कुछ समय बाद फिर से प्रयास करें", MessageBoxButtons.OK, MessageBoxIcon.Error); } else if (errCode == 2) { // Code 2 : Username/ E-mail address taken. MessageBox.Show("Username or E-mail taken. Please try another Username / E-Mail.", "Username/ E-Mail Already Exists\n कृपया अन्य उपयोगकर्ता नाम / ई-मेल की कोशिश करें", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else if (errCode == 3) { // Code 3 : No Database Connection. MessageBox.Show("Seems like I couldn't connect to Database.", "No Database Connection\n डाटाबेस कनेक्शन में समस्या", MessageBoxButtons.OK, MessageBoxIcon.Error); } else if (errCode == 4) { // Code 4 : Unknown Error MessageBox.Show("Houston, we have a problem! Please try again.", "Unknown Error Occured\n कृपया बाद में फिर से प्रयास करें", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } catch (Exception ex) { //resultShow.Text += ex; MessageBox.Show(string.Format("Some unhandled exception occured.\nError : {0}", ex), "Exception Occured!", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }