Advertisement
Guest User

Untitled

a guest
Nov 17th, 2016
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.75 KB | None | 0 0
  1. @Override
  2. protected String doInBackground(String... params) {
  3.  
  4. String insertUrl = "http://localhost/insert.php";
  5.  
  6. club_name = params[1];
  7. String publisher_name = params[2];
  8. String club_contact = params[3];
  9. String club_location = params[4];
  10. String club_hours = params[5];
  11. String club_age = params[6];
  12. String club_description = params[7];
  13.  
  14. try {
  15. URL url = new URL(insertUrl);
  16. HttpURLConnection httpURLConnection = (HttpURLConnection)url.openConnection();
  17. httpURLConnection.setRequestMethod("POST");
  18. httpURLConnection.setDoOutput(true);
  19. OutputStream outputStream = httpURLConnection.getOutputStream();
  20. BufferedWriter bufferedWriter = new BufferedWriter(new OutputStreamWriter(outputStream,"UTF-8"));
  21. String data = URLEncoder.encode("age","UTF-8")+"="+URLEncoder.encode(club_name,"UTF-8")+"&"+
  22. URLEncoder.encode("number","UTF-8")+"="+URLEncoder.encode(publisher_name,"UTF-8");
  23. // URLEncoder.encode("publisher_phone","UTF-8")+"="+URLEncoder.encode(club_contact,"UTF-8")+"&"+
  24. // URLEncoder.encode("location","UTF-8")+"="+URLEncoder.encode(club_location,"UTF-8")+"&"+
  25. // URLEncoder.encode("hour_open","UTF-8")+"="+URLEncoder.encode(club_hours,"UTF-8")+"&"+
  26. // URLEncoder.encode("age","UTF-8")+"="+URLEncoder.encode(club_age,"UTF-8")+"&"+
  27. // URLEncoder.encode("description","UTF-8")+"="+URLEncoder.encode(club_description,"UTF-8");
  28. bufferedWriter.write(data);
  29. bufferedWriter.flush();
  30. bufferedWriter.close();
  31. outputStream.close();
  32. InputStream inputStream = httpURLConnection.getInputStream();
  33. inputStream.close();
  34.  
  35.  
  36.  
  37. } catch (MalformedURLException e) {
  38. e.printStackTrace();
  39. } catch (IOException e) {
  40. e.printStackTrace();
  41. }
  42.  
  43. return "Party has been posted!";
  44. }
  45.  
  46. <?php
  47. require "connection.php";
  48.  
  49. $club_name = $_POST["club_name"];
  50. $publisher_name = $_POST["publisher_name"];
  51. $publisher_phone = $_POST["publisher_phone"];
  52. $location = $_POST["location"];
  53. $hour_open = $_POST["hour_open"];
  54. $age = $_POST["age"];
  55. $description = $_POST["description"];
  56.  
  57. $sql = "insert into apps(club_name,publisher_name,publisher_phone,location,hour_open,age,description) values ('$club_name','$publisher_name','$publisher_phone','$location','$hour_open','$age','$description')";
  58. $query = mysqli_query($conn,$sql);
  59.  
  60. ?>
  61.  
  62. <?php
  63. $db_name = "ori";
  64. $mysql_username = "root";
  65. $mysql_password = "";
  66. $server_name = "localhost";
  67. $conn = mysqli_connect($server_name,$mysql_username,$mysql_password,$db_name);
  68.  
  69. if($conn)
  70. {
  71. //echo "connects";
  72. }
  73. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement