数据库无法正确吸引用户

我开发了Android问卷调查应用程序,并假设数据库获得了包含答案的用户电子邮件 为新的注册正确地获得用户,但是当我注销并尝试与另一个用户一起使用时,它将在获得新答案的用户之前得到相同的结果

android代码

    private class BackTaskQuestion extends AsyncTask<Void, Void, Void> {

    protected Void doInBackground(Void... params) {

        nameValuePairs = new ArrayList<NameValuePair>(2);

        nameValuePairs.add(new BasicNameValuePair("answer", answer));
        nameValuePairs.add(new BasicNameValuePair("email", email));


        int dbResult = new SendDataToDB(nameValuePairs, "setUserAnswer.php").sendDataToDB();

        System.out.println("JSON Code: " + dbResult);

        if (dbResult == 0) {
            Intent i = new Intent(getApplicationContext(), ThankYou.class);
            startActivity(i);
            finish();
        } else {
            System.out.println("else ");
            Log.e("Error", "Failed - DB Issue");

            runOnUiThread(new Runnable() {
                public void run() {
                    Toast.makeText(getApplicationContext(), "Error!!", Toast.LENGTH_LONG).show();
                }
            });
        }
        return null;
    }
}

PHP代码

            $email=$_POST['email'];
    $answer=$_POST['answer'];
    $device_id=$_POST['device_id'];


    $sql = "Insert into PARTICIPATION
            (Answer,
            EMAIL, device_id
            )
            values
            ('$answer',
            '$email', '$device_id'
            )";


    $result = $con->query($sql);
    $flag['code']=10;

    if ($result === TRUE) {
        $flag['code']=0;
    }

    else {
       $flag['code']=1;
    }
   echo json_encode($flag, JSON_UNESCAPED_UNICODE);

   echo '$result';

   $con->close();
?>

我需要解决此冲突

评论