Answer the question
In order to leave comments, you need to log in
When registering on the site through the application, it gives an error Failure to register?
When registering on the site through the application, it gives an error Failure to register. What is the reason? Login works fine!
/** Enregistrement d'un utilisateur **/
private class createUser extends AsyncTask<String, Void, String> {
@Override
protected String doInBackground(String... params) {
String url = global_url+"user_register.php";
StringRequest jsonObjReq = new StringRequest(Request.Method.POST,
url,
new Response.Listener<String>() {
@Override
public void onResponse(String response) {
try {
progressBar_subs.setVisibility(View.INVISIBLE);
JSONObject json = new JSONObject(response);
JSONObject msg = json.getJSONObject("msg");
String etat = msg.getString("etat");
if(etat.equals("1")){
JSONObject user = json.getJSONObject("user");
phone_subs.setText("");
password_subs.setText("");
password_conf.setText("");
firstname_subs.setText("");
email_insc.setText("");
// Toast.makeText(context, "Successfully completed", Toast.LENGTH_SHORT).show();
if(account_type.equals("customer")){
saveProfile(new User(user.getString("id"),user.getString("nom"),user.getString("prenom"),user.getString("phone")
,user.getString("email"),user.getString("statut"),user.getString("login_type"),user.getString("tonotify"),user.getString("device_id"),
user.getString("fcm_id"),user.getString("creer"),user.getString("modifier"),user.getString("photo_path"),user.getString("user_cat"),"",user.getString("currency")
,"","" ,"","","","","",user.getString("country")));
}else{
id_driver = user.getString("id");
saveProfile(new User(user.getString("id"),user.getString("nom"),user.getString("prenom"),user.getString("phone")
,user.getString("email"),user.getString("statut"),user.getString("login_type"),user.getString("tonotify"),user.getString("device_id"),
user.getString("fcm_id"),user.getString("creer"),user.getString("modifier"),user.getString("photo_path"),user.getString("user_cat"),"",user.getString("currency")
,user.getString("statut_licence"),user.getString("statut_nic"),"","","","",user.getString("statut_vehicule"),user.getString("country")));
}
// phone_subs.setText(phone);
// Connexion.input_phone.setText(user.getString("phone"));
launchHomeScreen();
}else if(etat.equals("2")){
Toast.makeText(context, "This number already exists", Toast.LENGTH_SHORT).show();
requestFocus(phone_subs);
input_layout_phone_subs.setError("Enter another phone number");
}else
Toast.makeText(context, "Failure to register", Toast.LENGTH_SHORT).show();
} catch (JSONException e) {
}
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
progressBar_subs.setVisibility(View.INVISIBLE);
Toast.makeText(context, "Error "+error.getMessage(), Toast.LENGTH_SHORT).show();
}
}) {
@Override
protected Map<String, String> getParams() {
Map<String, String> params = new HashMap<String, String>();
params.put("firstname", val_firstname_subs);
params.put("phone", val_phone_subs);
params.put("password", val_password_subs);
params.put("email", val_email_subs);
params.put("account_type", account_type);
params.put("login_type", "phone");
params.put("tonotify", "yes");
return params;
}
};
else {
$insertdata = mysqli_query($con, "insert into tj_user_app(prenom,phone,mdp,statut,login_type,tonotify,creer)
values('$prenom','$phone','$mdp','yes','$login_type','$tonotify','$date_heure')");
$id = mysqli_insert_id($con);
if ($insertdata > 0) {
$response['msg']['etat'] = 1;
$get_user = mysqli_query($con, "select * from tj_user_app where id=$id");
$row = $get_user->fetch_assoc();
unset($row['mdp']);
$row['user_cat'] = "user_app";
$get_currency = mysqli_query($con, "select * from tj_currency where statut='yes' limit 1");
$row_currency = $get_currency->fetch_assoc();
$row['currency'] = $row_currency['symbole'];
$get_country = mysqli_query($con, "select * from tj_country where statut='yes' limit 1");
$row_country = $get_country->fetch_assoc();
$row['country'] = $row_country['code'];
// $get_commission = mysqli_query($con, "select * from tj_commission where statut='yes' limit 1");
// $row_commission = $get_commission->fetch_assoc();
// $row['commission'] = $row_commission['value'];
$response['user'] = $row;
} else {
$response['msg']['etat'] = 3;
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question