-4

I have a simple form I wnt to submit with PHP, unfortunately, I am getting an error, here is the error

Notice: Undefined index: comment in C:\custom-xammp\htdocs\zadania\welcome.php on line 5

Here is php script

<?php
if(isset($_POST['submit'])) 
{ 
    $name = $_POST['name'];
    $comment =$_POST['comment'];
    $radio = $_POST['MyRadio'];

    echo "Name : <b> $name </b>";
    echo "<br>Commennt: <b> $comment </b"; 
    echo "<br>Radido: <b> $radio </b"; 
}
?>
<form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">

   Name: <input type="text" name="name"><br><br>
   Text: <textarea name="comment" form="usrform">Enter text here...</textarea><br><br>
   Checkbox:  <input type="radio" name="MyRadio" value="Second" /><br><br>
   <input type="submit" name="submit" value="Submit Form"><br>
</form>

The only name return the value, the rest undefined

what is wrong here ?

David
  • 208,112
  • 36
  • 198
  • 279
The Dead Man
  • 6,258
  • 28
  • 111
  • 193

1 Answers1

2

Just delete the form="usrform" from the textarea, or add it as id to your form.

maio290
  • 6,440
  • 1
  • 21
  • 38