我需要添加什么代码,以便如果密码!=密码2然后中止注册,我不确定该怎么做,你能帮我吗?
httpclient=new DefaultHttpClient();
httppost= new HttpPost("http://purelymean.com/ANDROID/adduser.php"); // make sure the url is correct.
//add your data
nameValuePairs = new ArrayList<NameValuePair>(4);
// Always use the same variable name for posting i.e the android side variable name and php side variable name should be 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 by James from coderzheaven.. from 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 from PHP : " + response);
dialog.dismiss();
}
});