猿问

将变量从 android 客户端发布到 php 服务器时出错

我想做一个活动来更改用户个人资料。接收到的基于 JSON 的部分工作正常。我已经通过在 PHP 代码中手动设置变量进行了测试。但是,当我将变量从 android 发布到 php 时,它无法接收它。任何人都可以告诉我问题吗?


public class ProfilActivity extends AppCompatActivity {


private EditText editTextNama, editTextEmail, editTextPassword, editTextNohp;

private Button Simpan;

private static final String PROFIL_URL = "http://vrai-dev.000webhostapp.com/koneksi_profil.php";


List<Profil> profilList;


    @Override

    protected void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);

        setContentView(R.layout.activity_profil);


        Button back = (Button) findViewById(R.id.profil_back);

        back.setOnClickListener(new View.OnClickListener() {

            @Override

            public void onClick(View view) {

                Intent i = new Intent(ProfilActivity.this, MenuActivity.class);

                startActivity(i);

            }

        });


        profilList = new ArrayList<>();


        getEmail();


        editTextNama = (EditText) findViewById(R.id.profil_username);

        editTextEmail = (EditText) findViewById(R.id.profil_email);

        editTextPassword = (EditText) findViewById(R.id.profil_password);

        editTextNohp = (EditText) findViewById(R.id.profil_nohp);


        Simpan = (Button) findViewById(R.id.profil_simpan);

        Simpan.setOnClickListener(new View.OnClickListener() {

            @Override

            public void onClick(View view) {

                try {

                    updateProfil();

                } catch (IOException e) {

                    e.printStackTrace();

                }

            }

        });


    }

慕莱坞森
浏览 136回答 3
3回答

叮当猫咪

这是我用于获取电子邮件变量的 php 代码。有什么不对?<?phpdefine('DB_HOST','Localhost');define('DB_USER','id9815170_phpjember');define('DB_PASS','phpjember');define('DB_NAME','id9815170_phpjember');$conn = new mysqli(DB_HOST, DB_USER, DB_PASS, DB_NAME);if(mysqli_connect_errno()){&nbsp; &nbsp; die('Unable to connect to database ' . mysqli_connect_error());}$email = $_POST['email'];$stmt = $conn->prepare("SELECT foto_user, username, email, password, nohp FROM datauser WHERE email='$email';");$stmt->execute();$stmt->bind_result($foto_user, $username, $email, $password, $nohp);$profil = array();while($stmt->fetch()){&nbsp; &nbsp; $temp = array();&nbsp; &nbsp; $temp['foto_user'] = $foto_user;&nbsp; &nbsp; $temp['username'] = $username;&nbsp; &nbsp; $temp['email'] = $email;&nbsp; &nbsp; $temp['password'] = $password;&nbsp; &nbsp; $temp['nohp'] = $nohp;&nbsp; &nbsp; array_push($profil, $temp);}echo json_encode($profil);?>
随时随地看视频慕课网APP
我要回答