What potential issues can arise when using GET requests for writing data in PHP scripts?

Using GET requests for writing data in PHP scripts can pose security risks as the data is exposed in the URL and can be easily tampered with. It is recommended to use POST requests for writing data to ensure the data is not visible in the URL and to prevent accidental data exposure. Additionally, using GET requests for writing data can lead to limitations on the amount of data that can be sent.

if ($_SERVER['REQUEST_METHOD'] === 'POST') {
    // Process the data sent via POST request
} else {
    // Handle the case where a GET request is made for writing data
    http_response_code(405);
    echo 'Method Not Allowed';
    exit;
}