Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setting value of a HTML form textarea?

Tags:

html

php

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?

like image 700
Skizit Avatar asked Sep 10 '25 15:09

Skizit


2 Answers

Textarea has no value. You need to insert your message between the opening and closing tags.

<textarea><?php echo htmlspecialchars($message); ?></textarea>
like image 193
fabrik Avatar answered Sep 12 '25 10:09

fabrik


<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.

like image 27
sshow Avatar answered Sep 12 '25 09:09

sshow