Advertisement
Guest User

Untitled

a guest
Oct 31st, 2014
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.34 KB | None | 0 0
  1. try {
  2. URL obj = new URL("http://myphpurl/insert.php");
  3. HttpURLConnection conn = (HttpURLConnection) obj.openConnection();
  4. conn.setReadTimeout(10000);
  5. conn.setConnectTimeout(15000);
  6. conn.setRequestMethod(POST_METHOD);
  7. conn.setDoInput(true);
  8. conn.setDoOutput(true);
  9.  
  10. Map<String, String> params = new HashMap<String, String>();
  11. params.put("title", "العربية");
  12.  
  13. OutputStream os = conn.getOutputStream();
  14. BufferedWriter writer =
  15. new BufferedWriter(new OutputStreamWriter(os, "UTF-8"));
  16. writer.write(getQuery(params));
  17. writer.flush();
  18. writer.close();
  19. os.close();
  20.  
  21. BufferedReader in =
  22. new BufferedReader(new InputStreamReader(conn.getInputStream(), "UTF-8"));
  23. String inputLine;
  24. while ((inputLine = in.readLine()) != null) {
  25. response.append(inputLine);
  26. }
  27. LOG.debug("response {}", response);
  28.  
  29. in.close();
  30. response = null;
  31. inputLine = null;
  32. conn.disconnect();
  33. conn = null;
  34. obj = null;
  35. } catch (MalformedURLException e) {
  36. e.printStackTrace();
  37. } catch (IOException e) {
  38. e.printStackTrace();
  39. }
  40.  
  41. <?php
  42. $posttitle = $_POST["title"];
  43. echo "$posttitle";
  44. echo urldecode($posttitle);
  45. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement