Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot get the value of a textarea via post method [closed]

It is a very simple form as in the code below:

 <form method="POST" action="news.php?nid=2">
  <textarea id="txtcomment" style="width:100%; height: 70px;" maxlength="300"></textarea><br /><br />
  <input type="submit" class="button" style="float: right; cursor:pointer;" value="Comment">
 </form>

but in the news.php i cannot get the value of "txtcomment"

 echo $_POST['txtcomment'];

it returns nothing...

like image 986
medo ampir Avatar asked Nov 28 '22 00:11

medo ampir


2 Answers

It is because you need to name the textarea:

<textarea name="txtcomment"></textarea>

The id parameter does not have anything to do with how forms work (with the exception of labels, but that is not important here).

like image 145
Sverri M. Olsen Avatar answered Dec 06 '22 00:12

Sverri M. Olsen


Specify the name attribute of the textarea.

like image 45
Richard Avatar answered Dec 05 '22 23:12

Richard