Advertisement
Guest User

Untitled

a guest
Oct 7th, 2016
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.61 KB | None | 0 0
  1. String i = "";
  2.  
  3. String d = "";
  4.  
  5. String ya = "";
  6.  
  7.  
  8. String is = "";
  9.  
  10. String to="";
  11.  
  12. final Response.Listener<String> responseListener = new Response.Listener<String>() {
  13.  
  14. @Override
  15.  
  16.  
  17. public void onResponse(String response)
  18. {JSONObject jsonResponse = null;
  19.  
  20. try {
  21.  
  22. JSONArray array = new JSONArray(response);
  23.  
  24. jsonResponse = array.getJSONObject(0);
  25.  
  26. Log.w(TAG, "onResponse: jsonresponse" + response.toString());
  27.  
  28. boolean success = jsonResponse.getBoolean("success");
  29.  
  30. i = jsonResponse.getString("i");
  31.  
  32.  
  33.  
  34. d = jsonResponse.getString("d");
  35.  
  36.  
  37.  
  38. } else {
  39.  
  40. }
  41.  
  42. } catch (JSONException e) {
  43. e.printStackTrace();
  44. }}
  45.  
  46. Inp insQ = new Inp(ya,is ,to ,responseListener);
  47.  
  48. RequestQueue queue = Volley.newRequestQueue(main.this);
  49.  
  50. queue.add(insQ);}
  51.  
  52.  
  53. next ins class
  54. public class Ins extends StringRequest {
  55. public static final String REGISTER_REQUEST_URL = "edu.php";
  56.  
  57. private static final String TAG = "Ins";
  58. private Map<String,String> params;
  59. public Ins(String ya, String is, String to, Response.Listener listener)
  60. {
  61. super(Request.Method.POST, REGISTER_REQUEST_URL, listener, null);
  62. Log.w(TAG, "Ins: " + ya + is + to );
  63. params = new HashMap<>();
  64. params.put("ya", ya);
  65. params.put("is",is);
  66. params.put("to", to + "");
  67.  
  68.  
  69. Log.w(TAG, "Ins working well " + ya + is +to );
  70. } @Override
  71. public Map<String,String> getParams() {
  72.  
  73. return params;
  74.  
  75.  
  76. }
  77. }
  78.  
  79. $servername = "localhost";
  80. $username = "****";
  81. $password = "*****";
  82. $dbname="*****";
  83.  
  84.  
  85. $em=$_POST['ya'];
  86. $one=$_POST['is'];
  87. $to = $_POST['to'];
  88.  
  89.  
  90. $d = date('Y-m-d');
  91. $y=date('y');
  92. $m=date('m');
  93. $d=date('d'); $conn = mysqli_connect($servername, $username, $password, $dbname);
  94. if (!$conn) {
  95. die("Connection failed: " . mysqli_connect_error());
  96. }
  97. $sqll = "SELECT * FROM jio";
  98. $res = mysqli_query($conn,$sqll);
  99. $rowC = mysqli_num_rows($res);
  100.  
  101. $rowC = $rowC%999 + 1;
  102. if($rowC < 10){
  103. $i = $year.$mon.$day.'00'.$rowC;
  104. }elseif (rowC < 100) {
  105. $i = $year.$mon.$day.'0'.$rowC;
  106. }else {
  107. $i = $year.$mon.$day.$rowC;
  108. }
  109. $sql = "INSERT INTO jio(iu,i, d, ya, is, qs,to,ra,wto,wi,wk,)VALUES('0',".$i."','".$d."','".$em."','".$one."', '-1','".$to."','0','0','0','0')";
  110.  
  111. $r = mysqli_query($conn, $sql);
  112.  
  113. $rows=mysqli_affected_rows($conn);
  114.  
  115.  
  116. $result = array();
  117.  
  118. if($rows>0){
  119. array_push($result,array(
  120. 'success'=>true,
  121. 'i' => $i,
  122. 'd' =>$d
  123. ));}
  124. else
  125. array_push($result,array(
  126. 'success'=>false
  127.  
  128. ));
  129.  
  130. echo json_encode($result);
  131.  
  132. mysqli_close($conn);
  133. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement