I am using php to get textarea value using post method but getting a weird result with that let me show you my code
<form method="post" action="index.php">
<textarea id="contact_list" name="contact_list"></textarea>
<input type="submit" name="submit" value="Send" id="submit"/>
</form>
I am entering some names and their email address in the textarea, and everytime i echo the value or textarea it skips the email address and only showing the name let me show the way i am entering value in textarea
"name1" <[email protected]>, "name2" <[email protected]>
and once I will echo using php it will only echo the name and will skip the email address.
Code is supposed to get users nickname and input message, store both in database and retrieve it back to text area, smth similar to one man chat (whatever is typed after clicking 'Send message' should be stored to database and retrieved and shown in the text area).
<textarea> does not support the value attribute.
Use the <textarea> tag to show a text area. The HTML <textarea> tag is used within a form to declare a textarea element - a control that allows the user to input text over multiple rows. Specifies that on page load the text area should automatically get focus.
Definition and Usage. The <textarea> tag defines a multi-line text input control. The <textarea> element is often used in a form, to collect user inputs like comments or reviews. A text area can hold an unlimited number of characters, and the text renders in a fixed-width font (usually Courier).
Always (always, always, I'm not kidding) use htmlspecialchars()
:
echo htmlspecialchars($_POST['contact_list']);
Make sure your escaping the HTML characters
E.g.
// Always check an input variable is set before you use it
if (isset($_POST['contact_list'])) {
// Escape any html characters
echo htmlentities($_POST['contact_list']);
}
This would occur because of the angle brackets and the browser thinking they are tags.
See: http://php.net/manual/en/function.htmlentities.php
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With