<?php
//setting header to json 
    header('Content-Type: application/json');
    header("Access-Control-Allow-Origin: *");
    $driverID = $_POST["id"];  // get internal sensor id from js
    $gpio = $_POST["p"];

    require '../php/database.php';
    
    // get pinTypeName to send back to backend so we can update UI
    $query = sprintf("SELECT pinsType.pinTypeName FROM pinsAvailable LEFT JOIN pinsType ON pinsAvailable.pinTypeID = pinsType.pinTypeID WHERE driverID = '$driverID' AND gpio = '$gpio'");
    $result = $mysqli->query($query);  // execute query
    
    $dataWindow = array();
    foreach ($result as $row) {
        $dataWindow[] = $row;
    }
    //free memory associated with result
    $result->close();

    $mysqli->close();
    print json_encode($dataWindow);  // send data so javascript knows this ran
?>