I am creating a test form which I want to send the data entered to a php
. It sends me the Name and the Email but the text entered in TEXTAREA
it does not send it to me. I leave the code
feedback.html:
<form action="feed.php" method="post">
<table>
<tr>
<td >Your Name:</td>
</tr>
<tr>
<td ><input type="text" name="name" size="25" maxlength="30" /></td>
</tr>
<tr>
<td >Your Email Address:</td>
</tr>
<tr>
<td ><input type="text" name="email" size="25" maxlength="30" />
</td>
</tr>
<tr>
<td >Your Feddback:</td>
</tr>
<tr>
<td ><textarea rows="6" cols="40" name="feedback" form="usrform" >
</textarea></td>
</tr>
<tr>
<td colspan="2" align="center"><input style="margin-left:-80px;"
type="submit" value="Send Feddback" name="submit" /></td>
</tr>
</table>
</form>
feed.php:
<?php
$name = $_POST["name"];
$email = $_POST["email"];
$feedback = $_POST["feedback"];
echo $name . "</br>";
echo $email . "</br>";
echo $feedback . "</br>";
?>
By adding the attribute
form
inside an element, you are indicating to which form said element belongs to, this is beneficial for a particular case where the elements are not necessarily inside the formeg
When submitting such a form, you might think that you are not submitting the
textarea
, but since the attribute was addedform
it is also submitted and will be accessible from the place you are submitting to.In your example you are adding the attribute and there is no element
form
with that id so that element is not sent even if it is inside theform
.To solve your problem, you have two options, remove the attribute
form
sincetextarea
it is inside the tagsform
and it would not be necessary to add it, or add theid
to the form with the value it already has (usrform)