What are best practices for structuring PHP code when developing a CMS to avoid errors like form not submitting data?

When developing a CMS, it is important to properly structure your PHP code to ensure that forms submit data correctly. One common issue is not properly handling form submissions, which can lead to errors like data not being submitted. To avoid this, make sure to check if the form has been submitted before processing the data.

// Check if the form has been submitted
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    // Process form data here
}