Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Auto-populating a Textarea with PHP variables

Tags:

html

php

textarea

How do I auto-populate the text area below with two PHP variables, $submission and $fullurl?

<form method='post' action='index.php'>

<br />

<textarea  name="tweet" cols="50" rows="5" id="tweet" ></textarea>

<br />

<input type='submit' value='Tweet' name='submit' id='submit' />

</form>
like image 671
John Avatar asked Apr 28 '11 00:04

John


1 Answers

<textarea>s are given default values like so:

<textarea>value</textarea>

So use something like:

<textarea name="tweet" cols="50"rows="5" id="tweet"><?php echo $submission ?> <?php echo $fullurl ?></textarea>

Note that any whitespace is represented as-is in a textarea, so newlines will result in newlines in the textbox.

like image 133
Ross Avatar answered Sep 28 '22 07:09

Ross