Are there best practices for defining variables in input/submit elements in PHP forms?

When defining variables for input/submit elements in PHP forms, it is best practice to use the isset() function to check if the form has been submitted before accessing the form data. This helps prevent undefined variable errors and ensures that the variables are only set when the form is submitted.

<?php
if(isset($_POST['submit'])) {
    $input_value = $_POST['input_name'];
    // Process the form data here
}
?>

<form method="post" action="">
    <input type="text" name="input_name">
    <input type="submit" name="submit" value="Submit">
</form>