Setting value of a HTML form textarea?
I'm using the following to set the value of a text area..
<?php
$message = $_REQUEST['message'];
?>
<br/><b>Description</b><br/>
<TEXTAREA NAME="message" COLS=40 ROWS=6 value="<?=$message;?>"></TEXTAREA><br/><br/>
<input type="hidden" name="MAX_FILE_SIZE" value="1000000" />
but it doesn’t appear to be working. The value of message is not null. Does anyone have any idea why it's not filling the value?
Textarea has no value. You need to insert your message between the opening and closing tags.
<textarea><?php echo htmlspecialchars($message); ?></textarea>
<textarea name="message" cols="40" rows="6"><?=$message?></textarea>
Note: Make sure $message
is properly sanitized and that short_open_tag
is enabled. Otherwise, @fabric's accepted answer is a better answer.