What is the purpose of setting input fields to disabled in a PHP form and how does it affect data submission?

Setting input fields to disabled in a PHP form is useful when you want to display data to the user but prevent them from editing or submitting it. This can be helpful in scenarios where the data is read-only or should not be changed. However, it's important to note that disabled fields are not submitted with the form data, so if you need the data to be included in the submission, you should use readonly instead.

<form method="post">
  <input type="text" name="username" value="JohnDoe" disabled>
  <input type="submit" value="Submit">
</form>