<?php
    header('Content-Type: application/json');
    header("Access-Control-Allow-Origin: *");
    
    require '../php/database.php';

    $id = $_POST['i'];
    $pinID = $_POST['p'];
    $name = $_POST['n'];

    $sql = "UPDATE dosingPumps SET `doseName` = '$name' WHERE doseID = '$id'";
    
    if ($mysqli->query($sql) === TRUE) {
        echo "Record updated successfully";
    } else {
        echo "Error updating record: " . $mysqli->error;
    }
    
    $sql = "UPDATE pinsAvailable SET `name` = '$name' WHERE pinID = '$pinID'";
    
    if ($mysqli->query($sql) === TRUE) {
        echo "Record updated successfully";
    } else {
        echo "Error updating record: " . $mysqli->error;
    }

    $mysqli->close();
    