John Davidson

html - textarea comment to php

0 comments
Message:


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



My Answer:
To get the comment from a textarea in HTML and pass it to PHP, you can use a form with a textarea input and a submit button. Here's an example code snippet:

HTML:
html






PHP (process_comment.php):
php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$comment = $_POST["comment"];
// Do something with the comment, such as saving it to a database
echo "Comment submitted: " . $comment;
}
?>


In this example, when the form is submitted, the comment entered in the textarea will be sent to the `process_comment.php` file using the POST method. The PHP code in `process_comment.php` retrieves the comment from the `$_POST` superglobal array and can then process or store it as needed.

Rate this post

3 of 5 based on 1842 votes

Comments




© 2024 Hayatsk.info - Personal Blogs Platform. All Rights Reserved.
Create blog  |  Privacy Policy  |  Terms & Conditions  |  Contact Us