Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $host='localhost';
- $user='root';
- $password='';
- $db='employee101';
- $PLATE_NUM = $_POST["PLATE_NUM"];
- $PUV_TYPE = $_POST["PUV_TYPE"];
- $content = $_POST["content"];
- $sql = "select * from employee_data where PLATE_NUM like '$PLATE_NUM';";//first table where you retrieve the plate number first
- $sql_insert = "insert into employee_content (PLATE_NUM, PUV_TYPE, content) values('$PLATE_NUM', '$PUV_TYPE', '$content')";//insert the table
- $con = mysqli_connect($host,$user,$password,$db);
- $result = mysqli_query($con, $sql);
- $result2 = mysqli_query($con, $sql_insert);
- $response = array();
- if (mysqli_num_rows($result)> 0 && ($result2)=== TRUE ){
- echo"Log-In Success!!!!!!!!!!!!!!!!!!!!!!!!!!!!!";
- }else{
- echo "Log-In not success";
- }
- mysqli_close($con);
- ?>
- public void Button(View view) {
- String puv_plate = report_plate.getText().toString();
- String puv_type = report_type.getText().toString();
- String content = report_content.getText().toString();
- String type="report";
- BackgroundWorker backgroundWorker = new BackgroundWorker(this);
- backgroundWorker.execute(type, puv_plate,puv_type,content);
- }
- if(type.equals("report")){
- try {
- String id_ret = params[1];
- String puv_type = params[2];
- String report = params[3];
- URL url = new URL(retrieve_id);
- HttpURLConnection httpURLConnection = (HttpURLConnection)url.openConnection();
- httpURLConnection.setRequestMethod("POST");
- httpURLConnection.setDoOutput(true);
- httpURLConnection.setDoInput(true);
- OutputStream outputStream = httpURLConnection.getOutputStream();
- BufferedWriter bufferedWriter = new BufferedWriter(new OutputStreamWriter(outputStream, "UTF-8"));
- String post_data = URLEncoder.encode("PLATE_NUM","UTF-8")+"="+URLEncoder.encode(id_ret,"UTF-8") + "&"
- + URLEncoder.encode("PUV_TYPE", "UTF-8") + "=" + URLEncoder.encode(puv_type, "UTF-8") + "&"
- + URLEncoder.encode("content", "UTF-8") + "=" + URLEncoder.encode(report, "UTF-8");;
- bufferedWriter.write(post_data);
- bufferedWriter.flush();
- bufferedWriter.close();
- outputStream.close();
- InputStream inputStream = httpURLConnection.getInputStream();
- BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream, "iso-8859-1"));
- String result = "";
- String line = "";
- while((line = bufferedReader.readLine())!= null){
- result += line;
- }
- bufferedReader.close();
- inputStream.close();
- httpURLConnection.disconnect();
- return result;
- } catch (MalformedURLException e) {
- e.printStackTrace();
- } catch (IOException e) {
- e.printStackTrace();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement