Skip to content
PHP Logo

What are the differences between the "disabled" and "readonly" attributes in PHP form input fields?

The "disabled" attribute in PHP form input fields makes the input field uneditable and the value cannot be submitted with the form. On the other hand, the "readonly" attribute makes the input field read-only, meaning the value can be seen but not edited, and it will still be submitted with the form.

php
<form action="submit_form.php" method="post">
  <input type="text" name="disabled_field" value="Disabled Field" disabled>
  <input type="text" name="readonly_field" value="Readonly Field" readonly>
  <input type="submit" value="Submit">
</form>