title: PHP insert into MySQL database with REST
body: <p>I am attempting to test inserting in a database using a restful web service. I followed this tutorial <a href="https://trinitytuts.com/build-first-web-service-php/" rel="nofollow noreferrer">https://trinitytuts.com/build-first-web-service-php/</a>
  Whenever I post the data I get back successful but the database doesn't display the information (IE it created an entry but all the fields are blank). I am 75% sure it is the Advanced Rest Client but I don't know whats wrong with it. Here's the code/Post command.</p>
  
  <p>Post string is name=Apple&amp;email=banna%40orange.com&amp;pwd=12345&amp;status=ok, Picture of how I send it using Advanced Rest Client.</p>
  
  <p><img src="https://i.stack.imgur.com/bcdgk.png" alt="enter image description here"></p>
  
  <p>confi.php file</p>
  
  <pre><code> &lt;?php
   $conn = mysqli_connect("localhost", "root", "", 'tuts_rest');
   ?&gt;
  </code></pre>
  
  <p>Rest of the code</p>
  
  <pre><code>        &lt;?php
  
  include_once('confi.php');
  
  if($_SERVER['REQUEST_METHOD'] == "POST"){
  $name = isset($_POST['name']) ? mysqli_real_escape_string($_POST['name']) : "";
  $email = isset($_POST['email']) ? mysqli_real_escape_string($_POST['email']) : "";
  $password = isset($_POST['pwd']) ? mysqli_real_escape_string($_POST['pwd']) : "";
  $status = isset($_POST['status']) ? mysqli_real_escape_string($_POST['status']) : "";
  
   // Insert data into data base
   $sql = "INSERT INTO users (ID, name, email, password, status) VALUES ('' , '" . $name . "', '" . $email . "', '" . $password . "', '" . $status . "');";
   $qur = $conn-&gt;query($sql);
   if($qur){
   $json = array("status" =&gt; 1, "msg" =&gt; "Done User added!");
   }else{
   $json = array("status" =&gt; 0, "msg" =&gt; "Error adding user!");
   }
  }else{
   $json = array("status" =&gt; 0, "msg" =&gt; "Request method not accepted");
  }
  
  mysqli_close($conn);
  
  /* Output header */
   header('Content-type: application/json');
   echo json_encode($json);
  ?&gt;
  </code></pre>
  
  <p>Thank you!</p>