Issue using $_POST with a textarea

后端 未结 3 1094
难免孤独
难免孤独 2021-01-13 14:08

I have a simple contact form on a website that has 2 text fields, 1 textarea, and 1 hidden field.

For some reason, all the fields POST to a PHP script except the tex

相关标签:
3条回答
  • 2021-01-13 14:42

    You only need to add an ID value to the form and then add the form attribute to the textarea with the form ID value

    <form id="sample".....>
    <textarea name="aba" form="sample".....></textarea>
    </form>
    
    0 讨论(0)
  • 2021-01-13 14:54

    I once experienced an error similar to yours. What helped me was to use different id and name parameters. Try and see for yourself, because you have them identical here.

    0 讨论(0)
  • 2021-01-13 14:58

    Though in your case you don't have the textarea set to disabled, the reason I found this post was because I wasn't getting a value from a textarea that was. So here's a note for anyone else with that issue.

    To POST the value from a textarea where you want the field to be non-editiable, use readonly instead of disabled - either directly in html or via setAttribute in JavaScript - and then use CSS to highlight it, eg:

    textarea[readonly] {background-color:#F0F0F0;})
    
    0 讨论(0)
提交回复
热议问题