php - Cannot Get My Data From MySQL Android Volley Response -


can me one, i'm stuck login part. can register failed logged in.

login.java

//login volley request public void loginuser(){     final string useremail = edittextemailaddress.gettext().tostring().tolowercase().trim();     final string userpass = edittextpassword.gettext().tostring().trim();      //response true     response.listener<string> listener = new response.listener<string>() {         @override         public void onresponse(string response) {                 //json response                 try {                     jsonobject jsonobject = new jsonobject(response);                     boolean recordfound = jsonobject.getboolean("success");                      if (recordfound) {                         //get response server stored temporarily, shared preference                         //same order php code sequence                         string uniqueid = jsonobject.getstring("uniqueid");                         string usertype = jsonobject.getstring("usertype");                         string firstname = jsonobject.getstring("firstname");                         string lastname = jsonobject.getstring("lastname");                         string birthdate = jsonobject.getstring("birthdate");                         string gender = jsonobject.getstring("gender");                         string occupation = jsonobject.getstring("occupation");                         string datejoined = jsonobject.getstring("dateregister");                         string orgjoined = jsonobject.getstring("userorgjoined");                         string friends = jsonobject.getstring("userfriends");                         string volunteer = jsonobject.getstring("volunteeredtotal");                          //store current user logged in before go main- session start                         sharedpreferences usersharedpreference = loginactivity.this.getsharedpreferences(usersharedpreference.shared_preferences_holder, context.mode_private);                         sharedpreferences.editor speditor = usersharedpreference.edit();                         speditor.putboolean(serverscripts.login_response, true);                          //get data server database , save preference                         speditor.putstring(usersharedpreference.email_address, useremail);                         speditor.putstring(usersharedpreference.key_username_email_address, useremail);                         speditor.putstring(usersharedpreference.user_unique_id, uniqueid);                         speditor.putstring(usersharedpreference.first_name, firstname);                         speditor.putstring(usersharedpreference.last_name, lastname);                         speditor.putstring(usersharedpreference.gender, gender);                         speditor.putstring(usersharedpreference.birth_date, birthdate);                         speditor.putstring(usersharedpreference.occupation, occupation);                         speditor.putstring(usersharedpreference.user_joined_date, datejoined);                         speditor.putstring(usersharedpreference.user_type, usertype);                         speditor.putstring(usersharedpreference.user_unique_id, uniqueid);                         speditor.putstring(usersharedpreference.community_friends, friends);                         speditor.putstring(usersharedpreference.organization_joined, orgjoined);                         speditor.putstring(usersharedpreference.volunteered, volunteer);                           speditor.apply();                         progressdialoglogin.dismiss();                          intent intentstartmainactivity = new intent(loginactivity.this, mainactivity.class);                         intentstartmainactivity.putextra("emailaddress", usersharedpreference.email_address);                         intentstartmainactivity.putextra("firstname", usersharedpreference.first_name);                         intentstartmainactivity.putextra("lastname", usersharedpreference.last_name);                         startactivity(intentstartmainactivity);                         finish();                     }                 } catch (jsonexception e) {                     e.getstacktrace();                     //log.i("","get");                 }          }     };     //response false     response.errorlistener errorlistener = new response.errorlistener() {         @override         public void onerrorresponse(volleyerror error) {             string failed = error + "";             if (failed.equalsignorecase("failed")) {                 alertdialog.builder response = new alertdialog.builder(loginactivity.this);                 response.settitle(r.string.error)                         .setmessage(r.string.somethingwentwrong)                         .setpositivebutton("ok", new dialoginterface.onclicklistener() {                             @override                             public void onclick(dialoginterface dialog, int which) {                                 //do nothing                             }                         })                         .create()                         .show();             }         }     };      loginrequestvolley loginrequestvolley = new loginrequestvolley(useremail,userpass,listener,errorlistener);     requestqueue requestqueue = volley.newrequestqueue(loginactivity.this);     requestqueue.add(loginrequestvolley);     progressdialoglogin = new progressdialog(this);     progressdialoglogin.settitle("connecting server");     progressdialoglogin.setmessage("this may take few seconds. retrieving data...");     progressdialoglogin.getprogress();     progressdialoglogin.show(); } 

loginvolley.java

public class loginrequestvolley extends stringrequest { private static final string key_email = "emailaddress"; private static final string key_password = "password";  private map<string, string> params;  //for login volley public loginrequestvolley(string emailaddress, string password,                           response.listener<string> listener, response.errorlistener errorlistener){     super(method.post, serverscripts.php_script_path + serverscripts.php_login, listener, errorlistener);     params = new hashmap<>();     params.put(key_email,emailaddress);     params.put(key_password,password); }} 

php - log in userlogin.php

<?php   if($_server['request_method'] == 'post'){  //assign variables - holders     $useremail = $_post['emailaddress'];     $userpass = $_post['password'];      require('dbconnect.php');       //sqli statement - specific data          $sqli_login = "select uniqueid, usertype, firstname, lastname, gender,                           birthday, occupation, emailaddress, password ,dateregister,                           userorgjoined, userfriends, volunteeredtotal                            useryayong                            emailaddress = ? , password = ?";      $statement = mysqli_prepare($dbconnect,$sqli_login);       mysqli_stmt_bind_param($statement, "ss", $useremail,$userpass);      mysqli_stmt_execute($statement) or die("error:".mysqli_error($dbconnect));                          mysqli_stmt_store_result($results = $statement);       mysqli_stmt_bind_result($statement, $coluniqueid, $colusertype, $colfirstname,$collastname,                             $colgender, $colbirthday,$coloccupation,$colemail, $colpassword,                             $coldateregister,$coluserorgjoined,$coluserfriends,                             $colvolunteer);       //$recordsearch = mysqli_query($dbconnect, $sqli_login) or die("error".mysqli_error($dbconnect));           $recordfound = array();         $recordfound["success"] = false;       while(mysqli_stmt_fetch($results)){                         $recordfound["success"] = true;           $recordfound = $_post["uniqueid"] = $coluniqueid;         $recordfound = $_post["userdefaulttype"] = $colusertype;         $recordfound = $_post["userfirstname"] = $colfirstname;         $recordfound = $_post["userlastname"] = $collastname;         $recordfound = $_post["usergender"] = $colgender;         $recordfound = $_post["userbirthdate"] = $colbirthday;         $recordfound = $_post["useroccupation"] = $coloccupation;         $recordfound = $_post["userdateregister"] = $coldateregister;         $recordfound = $_post["userorgnojoined"] = $coluserorgjoined;         $recordfound = $_post["usernofriends"] = $coluserfriends;         $recordfound = $_post["volunteeredtotalno"] = $colvolunteer;      }         echo json_encode($recordfound);} 

i got debugging mode , trace it, got results debug

step to

the error in php code. response.

//login volley request public void loginuser(){ final string useremail =    edittextemailaddress.gettext().tostring().tolowercase().trim(); final string userpass = edittextpassword.gettext().tostring().trim();  //response true response.listener<string> listener = new response.listener<string>() {     @override     public void onresponse(string response) {             //json response             try {                 jsonarray array = response.getjsonarray("your_array");                 jsonobject jsonobject = array.getjsonobject(0);                  if (recordfound) {                     //get response server stored temporarily, shared preference                     //same order php code sequence                     string uniqueid = jsonobject.getstring("uniqueid");                     string usertype = jsonobject.getstring("usertype");                     string firstname = jsonobject.getstring("firstname");                     string lastname = jsonobject.getstring("lastname");                     string birthdate = jsonobject.getstring("birthdate");                     string gender = jsonobject.getstring("gender");                     string occupation = jsonobject.getstring("occupation");                     string datejoined = jsonobject.getstring("dateregister");                     string orgjoined = jsonobject.getstring("userorgjoined");                     string friends = jsonobject.getstring("userfriends");                     string volunteer = jsonobject.getstring("volunteeredtotal");                      //store current user logged in before go main- session start                     sharedpreferences usersharedpreference = loginactivity.this.getsharedpreferences(usersharedpreference.shared_preferences_holder, context.mode_private);                     sharedpreferences.editor speditor = usersharedpreference.edit();                     speditor.putboolean(serverscripts.login_response, true);                      //get data server database , save preference                     speditor.putstring(usersharedpreference.email_address, useremail);                     speditor.putstring(usersharedpreference.key_username_email_address, useremail);                     speditor.putstring(usersharedpreference.user_unique_id, uniqueid);                     speditor.putstring(usersharedpreference.first_name, firstname);                     speditor.putstring(usersharedpreference.last_name, lastname);                     speditor.putstring(usersharedpreference.gender, gender);                     speditor.putstring(usersharedpreference.birth_date, birthdate);                     speditor.putstring(usersharedpreference.occupation, occupation);                     speditor.putstring(usersharedpreference.user_joined_date, datejoined);                     speditor.putstring(usersharedpreference.user_type, usertype);                     speditor.putstring(usersharedpreference.user_unique_id, uniqueid);                     speditor.putstring(usersharedpreference.community_friends, friends);                     speditor.putstring(usersharedpreference.organization_joined, orgjoined);                     speditor.putstring(usersharedpreference.volunteered, volunteer);                       speditor.apply();                     progressdialoglogin.dismiss();                      intent intentstartmainactivity = new intent(loginactivity.this, mainactivity.class);                     intentstartmainactivity.putextra("emailaddress", usersharedpreference.email_address);                     intentstartmainactivity.putextra("firstname", usersharedpreference.first_name);                     intentstartmainactivity.putextra("lastname", usersharedpreference.last_name);                     startactivity(intentstartmainactivity);                     finish();                 }             } catch (jsonexception e) {                 e.getstacktrace();                 //log.i("","get");             }      } }; //response false response.errorlistener errorlistener = new response.errorlistener() {     @override     public void onerrorresponse(volleyerror error) {         string failed = error + "";         if (failed.equalsignorecase("failed")) {             alertdialog.builder response = new alertdialog.builder(loginactivity.this);             response.settitle(r.string.error)                     .setmessage(r.string.somethingwentwrong)                     .setpositivebutton("ok", new dialoginterface.onclicklistener() {                         @override                         public void onclick(dialoginterface dialog, int which) {                             //do nothing                         }                     })                     .create()                     .show();         }     } };  loginrequestvolley loginrequestvolley = new loginrequestvolley(useremail,userpass,listener,errorlistener); requestqueue requestqueue = volley.newrequestqueue(loginactivity.this); requestqueue.add(loginrequestvolley); progressdialoglogin = new progressdialog(this); progressdialoglogin.settitle("connecting server"); progressdialoglogin.setmessage("this may take few seconds. retrieving data..."); progressdialoglogin.getprogress(); progressdialoglogin.show(); } 

Comments

Popular posts from this blog

scala - 'wrong top statement declaration' when using slick in IntelliJ -

c# - DevExpress.Wpf.Grid.InfiniteGridSizeException was unhandled -

PySide and Qt Properties: Connecting signals from Python to QML -