Advertisement
Guest User

Untitled

a guest
Aug 9th, 2017
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.15 KB | None | 0 0
  1. <?php
  2. $host='localhost';
  3. $user='root';
  4. $password='';
  5. $db='employee101';
  6.  
  7. $PLATE_NUM = $_POST["PLATE_NUM"];
  8. $PUV_TYPE = $_POST["PUV_TYPE"];
  9. $content = $_POST["content"];
  10.  
  11. $sql = "select * from employee_data where PLATE_NUM like '$PLATE_NUM';";//first table where you retrieve the plate number first
  12. $sql_insert = "insert into employee_content (PLATE_NUM, PUV_TYPE, content) values('$PLATE_NUM', '$PUV_TYPE', '$content')";//insert the table
  13.  
  14. $con = mysqli_connect($host,$user,$password,$db);
  15.  
  16. $result = mysqli_query($con, $sql);
  17. $result2 = mysqli_query($con, $sql_insert);
  18. $response = array();
  19.  
  20. if (mysqli_num_rows($result)> 0 && ($result2)=== TRUE ){
  21. echo"Log-In Success!!!!!!!!!!!!!!!!!!!!!!!!!!!!!";
  22. }else{
  23. echo "Log-In not success";
  24. }
  25.  
  26. mysqli_close($con);
  27.  
  28. ?>
  29.  
  30. public void Button(View view) {
  31.  
  32. String puv_plate = report_plate.getText().toString();
  33. String puv_type = report_type.getText().toString();
  34. String content = report_content.getText().toString();
  35. String type="report";
  36. BackgroundWorker backgroundWorker = new BackgroundWorker(this);
  37. backgroundWorker.execute(type, puv_plate,puv_type,content);
  38. }
  39.  
  40. if(type.equals("report")){
  41. try {
  42. String id_ret = params[1];
  43. String puv_type = params[2];
  44. String report = params[3];
  45.  
  46. URL url = new URL(retrieve_id);
  47. HttpURLConnection httpURLConnection = (HttpURLConnection)url.openConnection();
  48. httpURLConnection.setRequestMethod("POST");
  49. httpURLConnection.setDoOutput(true);
  50. httpURLConnection.setDoInput(true);
  51. OutputStream outputStream = httpURLConnection.getOutputStream();
  52. BufferedWriter bufferedWriter = new BufferedWriter(new OutputStreamWriter(outputStream, "UTF-8"));
  53. String post_data = URLEncoder.encode("PLATE_NUM","UTF-8")+"="+URLEncoder.encode(id_ret,"UTF-8") + "&"
  54. + URLEncoder.encode("PUV_TYPE", "UTF-8") + "=" + URLEncoder.encode(puv_type, "UTF-8") + "&"
  55. + URLEncoder.encode("content", "UTF-8") + "=" + URLEncoder.encode(report, "UTF-8");;
  56. bufferedWriter.write(post_data);
  57. bufferedWriter.flush();
  58. bufferedWriter.close();
  59. outputStream.close();
  60. InputStream inputStream = httpURLConnection.getInputStream();
  61. BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream, "iso-8859-1"));
  62. String result = "";
  63. String line = "";
  64. while((line = bufferedReader.readLine())!= null){
  65. result += line;
  66. }
  67. bufferedReader.close();
  68. inputStream.close();
  69. httpURLConnection.disconnect();
  70. return result;
  71. } catch (MalformedURLException e) {
  72. e.printStackTrace();
  73. } catch (IOException e) {
  74. e.printStackTrace();
  75. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement