Advertisement
ghadeer

problem in update user data (android,Mysql)

Mar 20th, 2016
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.55 KB | None | 0 0
  1. i try to make user update his/her profile, the php code is work will, but the problem when i
  2. try to enter data by android aplication nothing change in database, and nothing wrong appeare in logcat.
  3. what is the problem?
  4.  
  5.  
  6.  
  7.  
  8.  
  9. public class MainActivity extends AppCompatActivity {
  10.  
  11. EditText et1,et2,et3,et4;
  12. Button saveupdate;
  13. String finalUrl;
  14.  
  15. @Override
  16. protected void onCreate(Bundle savedInstanceState) {
  17. super.onCreate(savedInstanceState);
  18. setContentView(R.layout.activity_main);
  19.  
  20. et1 = (EditText) findViewById(R.id.username);
  21. et2 = (EditText) findViewById(R.id.userpass);
  22. et3 = (EditText) findViewById(R.id.useremail);
  23. et4 = (EditText) findViewById(R.id.useraddress);
  24.  
  25. saveupdate = (Button) findViewById(R.id.button2);
  26. saveupdate.setOnClickListener(new View.OnClickListener() {
  27. @Override
  28. public void onClick(View v) {
  29.  
  30. String username = et1.getText().toString();
  31. String password = et2.getText().toString();
  32. String email = et3.getText().toString();
  33. String address = et4.getText().toString();
  34.  
  35. // encoding url to accept all characters
  36. final String url = "http://192.168.56.1/lesson6hiniwear/updateuser.php";
  37. final String usernamekey = "?name=";
  38. final String passwordkey = "&password=";
  39. final String emailkey = "&email=";
  40. final String addresskey = "&address=";
  41.  
  42. try {
  43. finalUrl = url + usernamekey + URLEncoder.encode(username, "UTF-8") + passwordkey + URLEncoder.encode(password, "UTF-8")
  44. + emailkey + URLEncoder.encode(email, "UTF-8") + addresskey + URLEncoder.encode(address, "UTF-8");
  45. } catch (UnsupportedEncodingException e) {
  46. e.printStackTrace();
  47. }
  48.  
  49. Runnable runnable = new Runnable() {
  50. @Override
  51. public void run() {
  52. try {
  53. URL updateuserUrl = new URL(url);
  54. // استقبال الاتصال بداخل الكلاس HttpUrlConnection
  55. HttpURLConnection userConnection = (HttpURLConnection) updateuserUrl.openConnection();
  56. // convert the bytes Stream comes from URL to character stream
  57. InputStreamReader stream = new InputStreamReader(userConnection.getInputStream());
  58. // convert character stream to something java can understand it
  59. BufferedReader ourStreamReader = new BufferedReader(stream);
  60. //extract the text from the stream in String
  61. final String Result = ourStreamReader.readLine();
  62. runOnUiThread(new Runnable() {
  63. @Override
  64. public void run() {
  65. Toast.makeText(MainActivity.this,Result,Toast.LENGTH_SHORT).show();
  66. }
  67. });
  68. } catch (IOException e) {
  69. e.printStackTrace();
  70. }
  71. }
  72. };
  73. // open new thread
  74. Thread thread = new Thread(runnable);
  75. thread.start();
  76. }
  77. });
  78.  
  79.  
  80. }
  81. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement