Home > Back-end >  textarea comment to php
textarea comment to php

Time:10-05

I'm trying to get the comment from text area only from html that will appear in php


  <form action="Untitled-2.php" method="post"></form>
    <b>Comment:</b><br>
    <textarea rows="5" cols="60" name="comment" placeholder="Enter your comment">
     </textarea><br>

    <p>Would you recommend this game to others?</p>
      <input type="radio" name="choice" required>
      <label for="yes">Yes</label><br>
      <input type="radio" name="choice">
      <label for="no">No</label><br>

    <p>Can we use your testimonial on our website?</p>
      <input type="radio" name="choice2" required>
      <label for="yes">Yes</label><br>
      <input type="radio" name="choice2">
      <label for="no">No</label><br><br>

    <input type="submit" value="Save">
    <input type="reset" value="Clear">
</fieldset>
</form>

what should I write in php to get the "Comment" from text area when i push the save button

CodePudding user response:

In you PHP file you can access it via the $_POST superglobal, like this $_POST['comment']

CodePudding user response:

Firstly remove before <b>Comment:</b><br> and secondly you must open <fieldset> To retrieve this value, do: $_POST['comment']

CodePudding user response:

You have a error in your first line remove form closing tag from first line.

then in untitled-2.php file write following code

<?php

echo $_POST['comment'];
  • Related