What role does the method attribute play in HTML forms when submitting data to PHP scripts?

The method attribute in HTML forms specifies the HTTP method used when submitting data to PHP scripts. The two most common methods are GET and POST. GET appends the form data to the URL, while POST sends the data in the body of the request. When submitting sensitive data or large amounts of data, it is recommended to use POST to ensure security and prevent data size limitations.

<form method="POST" action="submit.php">
  <!-- Form fields go here -->
  <input type="submit" value="Submit">
</form>