title: Kotlin POST request
body: <p>I'm new in Kotlin. I wanna ask about POST request.</p>
  
  <p>I want to pass "nim", "nama", and "address" edittext.text to database. But on my code, the Toast "Error Occured" is still appear and database didn't get any data. What should i do then?</p>
  
  <pre><code>override fun onCreate(savedInstanceState: Bundle?) {
      super.onCreate(savedInstanceState)
      setContentView(R.layout.activity_main)
  
      val jsonobj = JSONObject()
  
      jsonobj.put("nim", nim_editText.text)
      jsonobj.put("nama", nama_editText.text)
      jsonobj.put("address", address_editText.text)
  
      val queue = Volley.newRequestQueue(this)
      val url = "http://192.168.100.7/simplecrud/create.php"
  
      val req = JsonObjectRequest(Request.Method.POST,url,jsonobj,
          Listener {
              Toast.makeText(this@MainActivity, "Success", Toast.LENGTH_SHORT).show()
          },
          ErrorListener {
              Toast.makeText(this@MainActivity, "Error Occured", Toast.LENGTH_SHORT).show()
          })
  
  
      val btn = findViewById&lt;Button&gt;(R.id.button1)
  
      btn.setOnClickListener(object : View.OnClickListener {
          override fun onClick(v: View?) {
              queue.add(req)
          }
      })
  </code></pre>
  
  <p>this is my create.php code</p>
  
  <pre><code>    &lt;?php
  
  require_once('connection.php');
  
  $nim        = $_POST['nim'];
  $name       = $_POST['name'];
  $address    = $_POST['address'];
  $gender     = $_POST['gender'];
  
  if(!$nim || !$name || !$address || !$gender ){
      echo json_encode(array('message'=&gt;'required field is empty.'));
  }
      else{
          $query = mysqli_query($CON, "INSERT INTO tb_student VALUES ('$nim','$name','$address','$gender')");
  
      if($query){
          echo json_encode(array('message'=&gt;'student data successfully added.'));
      }
          else{
              echo json_encode(array('message'=&gt;'student data failed to add.'));
          }
  }
  
  ?&gt;
  </code></pre>