What could be causing a 406 error in PHP form submissions?

A 406 error in PHP form submissions typically occurs when the server cannot fulfill the request due to the client's request headers not being acceptable. This could be caused by incorrect content types or encoding in the form submission. To solve this issue, ensure that the form submission includes the correct content type and encoding that the server expects.

header('Content-Type: application/json');
echo json_encode(['message' => 'Form submitted successfully']);
exit;