如何使用android和php更新记录。当我在android中更新记录时,没有更新特定电子邮件上的任何记录,我猜测我的php上的代码有问题。
这是我在android上的代码
public void changeprofile(){
HashMap postData = new HashMap();
String emailch = emailchange.getText().toString();
String password = passch.getText().toString();
String firstname = fnamech.getText().toString();
String lastname = lnamech.getText().toString();
String contact = contactch.getText().toString();
String confirm = conpassch.getText().toString();
postData.put("emailc", emailch);
postData.put("fname", firstname);
postData.put("lname", lastname);
postData.put("Password", password);
postData.put("Confirm", confirm);
postData.put("contact", contact);
PostResponseAsyncTask task79 = new PostResponseAsyncTask(ChangeProfile.this, postData, new AsyncResponse() {
@Override
public void processFinish(String s) {
Log.d(LOG, s);
if (s.contains("change")) {
Toast.makeText(ChangeProfile.this, "Successfully Change Profile", Toast.LENGTH_LONG).show();
Intent in = new Intent(ChangeProfile.this, ProfileActivity.class);
startActivity(in);
} else if (s.contains("match")) {
Toast.makeText(ChangeProfile.this, "The password didnt match", Toast.LENGTH_LONG).show();
} else if (s.contains("Fillup")) {
Toast.makeText(ChangeProfile.this, "Fill up the form", Toast.LENGTH_LONG).show();
} else {
Toast.makeText(ChangeProfile.this, "Invalid Credentials", Toast.LENGTH_LONG).show();
}
}
});
task79.execute("http://10.0.2.2/wawi/change.php");
}
这是php(change.php)上的代码
require_once('connection.php');
if(isset($_POST['fname'])){
$email = $_POST['emailc'];
$fname = $_POST['fname'];
$lname = $_POST['lname'];
$password = $_POST['Password'];
$confirm = $_POST['Confirm'];
$contact = $_POST['contact'];
if( $password == '' || $confirm == '' || $fname == '' || $lname == '' || $contact== ''){
echo 'Fillup';
}else{
if($confirm == $password)
{
mysql_query("UPDATE users SET password='$password', fname='$fname', lname='$lname', contact='$contact' WHERE email='$email'");
echo "change";
}else
{
echo "match";
}