Send data from next js react hook form to php backend [duplicate]

I am trying to send data from a next js frontend to a php backend to populate my mysql database. I am trying to get it to connect but I am stuck as I am noob at php.

This is my next js form

const onSubmit = async (data: ShopFormValues) => {
        setLoading(true)
        try {        
            const response = await fetch("https://***********.com/register.php", {
                method: "POST",
                body: JSON.stringify({ firstname: "example" }),
                // ...
            });
            
            console.log(response)
        } catch (error: any) {
            console.log('Network error!')
        }
        finally {
            setLoading(false)
        }

    };

and this is my register.php file

<?php

    header("Access-Control-Allow-0rigin: *");
    header("Access-Control-Allow-Headers: *");

    $servername = "localhost";
    $database = "*********";
    $username = "************";
    $password = "************";
    $conn = new mysqli($servername, $username, $password, $database);
    
    if(isset($_POST['firstname'])){
        echo 'hello';
    }
    else {
        echo 'wa';
    }
?>

How can i confirm that the register.php file is receiving the data and send back a response?