title: Array to string conversion C:\xampp\htdocs\8990API\register.php
body: <p>As a beginner ionic dev I really don't have enough knowledge about the back-end especially arrays. I hope you guys takes time to answer this. </p>
  
  <p>register.php</p>
  
  <pre><code>&lt;?php
  
  if (isset($_SERVER['HTTP_ORIGIN'])) {
          header("Access-Control-Allow-Origin: {$_SERVER['HTTP_ORIGIN']}");
          header('Access-Control-Allow-Credentials: true');
          header('Access-Control-Max-Age: 86400');    // cache for 1 day
      }
  
      // Access-Control headers are received during OPTIONS requests
      if ($_SERVER['REQUEST_METHOD'] == 'OPTIONS') {
  
          if (isset($_SERVER['HTTP_ACCESS_CONTROL_REQUEST_METHOD']))
              header("Access-Control-Allow-Methods: GET, POST, OPTIONS");         
          if (isset($_SERVER['HTTP_ACCESS_CONTROL_REQUEST_HEADERS']))
              header("Access-Control-Allow-Headers:        {$_SERVER['HTTP_ACCESS_CONTROL_REQUEST_HEADERS']}");
  
          exit(0);
      }
  
    require "dbconnect.php";
  
      $data = file_get_contents("php://input");
      if (isset($data)) {
          $request = json_decode($data);
          $firstname = $request-&gt;firstname;
          $lastname = $request-&gt;lastname;
          $username = $request-&gt;username;
          $userrole = $request-&gt;userrole;
          $userpass = $request-&gt;userpass;
      }
  
  $firstname = stripslashes($firstname);
  $userpass = stripslashes($userpass);
  $userpass = sha1($userpass."@la]#}^(dy*%-Ga=/,Ga!.");
  
  $sql = "INSERT INTO useraccount (firstname, lastname, username, userrole, userpass)
          VALUES ('$firstname', '$lastname', '$username', '$userrole', '$userpass')";
  
  if ($con-&gt;query($sql) === TRUE) {
      $status = "success";
      $message = "New account created successfully";
  } 
  
  else {
      $status = "fail";
      $message =  "Error: " . $sql . "&lt;br&gt;" . $con-&gt;error;
  }
  
  echo json_encode(array('status' =&gt; $status, 'message' =&gt; $message, 'data' =&gt; $data));
  
  ?&gt;
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/0dA30.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/0dA30.png" alt="enter image description here"></a></p>
  
  <p><a href="https://i.stack.imgur.com/GqkJ3.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/GqkJ3.png" alt="enter image description here"></a></p>