Read a submitted HTML <textarea> through $_POST, using the control’s exact name as the array key. For a field declared as <textarea name="descrp">, the PHP lookup is:
$descript = $_POST['descrp'];
The SitePoint example failed because the PHP code used $_POST['decrp']—the s was missing. PHP keys must match the form field name exactly.
Use the textarea’s name, not its id
In HTML, name determines the key sent with a successful form submission. The id is primarily for labels, CSS, JavaScript and browser-side targeting. MDN documents this distinction for the <textarea> element: https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/textarea.
<form method="post" action="save.php">
<textarea name="descrp" id="descrip"></textarea>
<button type="submit">Save</button>
</form>
Read that value in save.php with:
$descript = $_POST['descrp'];
PHP describes $_POST as the associative array populated for POST requests using application/x-www-form-urlencoded or multipart/form-data: https://www.php.net/manual/en/reserved.variables.post.php.
#1 Best Overall
Why an “undefined index” appears
An undefined-index warning means the requested key was not present in the received array. In the SitePoint discussion, the form used name="descrp", while the PHP code requested $_POST['decrp']. Those are different keys.
| HTML field | Correct PHP key | Incorrect examples |
|---|---|---|
name="descrp" |
$_POST['descrp'] |
$_POST['decrp'], $_POST['descrip'] |
Checklist when the value is missing
- Confirm the textarea is inside the submitted form. Controls outside that form are not included in its submission.
- Give it a
name. Anidalone does not create a POST key. - Match spelling and capitalization exactly. Use the literal value from
name. - Check the form method and action. The form should use
method="post"and submit to the PHP script you are inspecting. - Inspect the received data temporarily. Put this at the start of the action script:
var_dump($_POST);
The output shows whether the request arrived and which keys PHP received. Remove the diagnostic output after troubleshooting. The original SitePoint thread also noted that the screenshot and posted code initially showed different forms, so verify the actual markup in the browser: https://www.sitepoint.com/community/t/how-do-i-retrieve-textarea-value-from-php/342828.
Rank #2
Handle an optional textarea safely
If the field may legitimately be omitted, test for the key before reading it:
$descript = $_POST['descrp'] ?? '';
This avoids an undefined-key warning and uses an empty string when no value was submitted. For a required field, validate the resulting value and return an appropriate error instead of silently accepting missing input.
Recommended Free Tools
When $_POST is the wrong reader
$_POST is for standard URL-encoded or multipart form bodies. If JavaScript sends JSON, XML or another content type, read the raw request body through php://input and decode it according to that format. The PHP manual documents the distinction at https://www.php.net/manual/en/reserved.variables.post.php.
$raw = file_get_contents('php://input');
$data = json_decode($raw, true);
$descript = $data['descrp'] ?? '';
Input filtering is optional
filter_input() can retrieve and filter external request input, but it does not correct a misspelled key. Fix the name-to-key match first; consult the function reference for filtering options: https://www.php.net/manual/en/function.filter-input.php.
Rank #4
The Bottom Line
For a normal POST form, give the textarea name="descrp" and read it as $_POST['descrp']. The key must match exactly; use var_dump($_POST) to diagnose a missing value, and use php://input instead when the request body is JSON or another non-form format.
Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.
Free tools Windows power users keep installed
One-click scans. No signup required.




