Register form with Password check android sdk -
all bit of code need add if password != password2 abort register, im unsure of how that, can please assit me?
httpclient=new defaulthttpclient(); httppost= new httppost("http://purelymean.com/android/adduser.php"); // make sure url correct. //add data namevaluepairs = new arraylist<namevaluepair>(4); // use same variable name posting i.e android side variable name , php side variable name should similar, namevaluepairs.add(new basicnamevaluepair("username",usern.gettext().tostring().trim())); // $edittext_value = $_post['edittext_value']; namevaluepairs.add(new basicnamevaluepair("password",password.gettext().tostring().trim())); namevaluepairs.add(new basicnamevaluepair("password2",password2.gettext().tostring().trim())); namevaluepairs.add(new basicnamevaluepair("email",email.gettext().tostring().trim())); if (password != password2) { toast.maketext(register.this,"passwords dont match",toast.length_short).show(); } httppost.setentity(new urlencodedformentity(namevaluepairs)); //execute http post request response=httpclient.execute(httppost); // edited james coderzheaven.. here.... responsehandler<string> responsehandler = new basicresponsehandler(); final string response = httpclient.execute(httppost, responsehandler); system.out.println("response : " + response); runonuithread(new runnable() { public void run() { tv.settext("response php : " + response); dialog.dismiss(); } });
don't use password != password2 comparing strings.to compare strings use string1.equals(string2). if condition false toast passwords not match , cancel registration.
if (!(password.equals(password2))) { toast.maketext(register.this,"passwords dont match",toast.length_short).show(); }
Comments
Post a Comment