Reputation: 3101
I want to have a text-field (input type="text") or text-area in html that takes users input. After "submit" clicked, PHP returns results. I want to repopulate the text-field or text-area with original user input. However my code only works with text-field, but not text-area:
This works:
<INPUT TYPE = "text" NAME = "seqbox" SIZE = 50 PLACEHOLDER = "Enter sequence here" VALUE = "<?php if(isset($_GET['seqbox'])) {echo $_GET['seqbox'];} ?>">
This does not work:
<TEXTAREA NAME = "seqbox" COLS=100 ROWS=20 PLACEHOLDER = "Enter sequence here" VALUE = "<?php if(isset($_GET['seqbox'])) {echo $_GET['seqbox'];} ?>"></TEXTAREA>
Any idea why? Thanks!
Upvotes: 0
Views: 555
Reputation: 180177
Textareas don't take a value
attribute.
<TEXTAREA NAME = "seqbox" COLS=100 ROWS=20 PLACEHOLDER = "Enter sequence here"><?php if(isset($_GET['seqbox'])) {echo $_GET['seqbox'];} ?></TEXTAREA>
A note: you should run $_GET['seqbox']
through htmlspecialchars
or malicious users will be able to inject things like JavaScript into your page through a specially crafted URL (an XSS vulnerability).
Upvotes: 0
Reputation: 536
Textarea doesn't have a value property. You need to set it in between the element like this:
<TEXTAREA NAME = "seqbox" COLS=100 ROWS=20 PLACEHOLDER = "Enter sequence here">
<?php if(isset($_GET['seqbox'])) {echo $_GET['seqbox'];} ?>
</TEXTAREA>
Upvotes: 1