如何使用implode和explode插入单个数据

I want to insert single data into SQL. I have instert table and first and lastname I will post data to service.php using implode and in service I will exlope data and add into a database. But it doesn't work.

Here is my inser.php page

     if($_POST)
    {
    $first_name = ($_POST['first_name']);
    $last_name  = ($_POST['last_name']);

    $query=$first_name.'|'.$last_name;
    $params=array(
        'action' => "INSERTSINGLE",
        'query' => $query
    );
    $postData='';
    foreach($params as $k => $v){
        $postData .= $k . '='.$v.'&';
    }
    rtrim($postData, '&');
    if(is_array($postData)){
        $count=count($postData);
    }else{
        $count=0;
    }
    print_r($postData);
    $ch=curl_init();
    curl_setopt($ch, CURLOPT_URL,"service.php");
    curl_setopt($ch, CURLOPT_RETURNTRANSFER,true);
    curl_setopt($ch, CURLOPT_HEADER,false);
    curl_setopt($ch, CURLOPT_POST,$count);
    curl_setopt($ch, CURLOPT_POSTFIELDS,$postData);
    curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: 
            application/json'));
    $responsedata=curl_exec($ch);
    curl_close($ch);
    print_r($responsedata);
}

and here is my webservice page

require_once('index.php');
$action=$_POST["action"];

echo $action;
$query = $_POST["query"];
$gelendata=explode('|',$query);
$firstname=$gelendata[0];
$lastname=$gelendata[1];
switch ($action)
{
case 'GETCLIENTS':

echo $firstname;
$query = $myPDO->query("SELECT * FROM users",PDO::FETCH_ASSOC);
foreach ($query as $row) {
    echo $row['first_name']."-".$row['last_name']."<br />
";
}
break;
case 'GETCLIENT':
echo 'client çekildi.';
$query = $myPDO->query("SELECT * FROM users WHERE user_id='{$query}'")->fetch(PDO::FETCH_ASSOC);
print_r($query);
break;
case 'INSERTSINGLE':
echo 'client çekildi.';
$query = $myPDO->query("INSERT INTO users (firs_name,last_name) VALUES({$firstname},{$lastname})")->fetch(PDO::FETCH_ASSOC);
print_r($query);
break;

I can take the data but I can not insert. Can you please forward me? Thanks...

case 'INSERTSINGLE':
echo 'client çekildi.';
$query = $myPDO->query("INSERT INTO users (firs_name,last_name) VALUES('{$firstname}','{$lastname}')")->fetch(PDO::FETCH_ASSOC);
print_r($query);
break;