Page 1 of 1

Posting DB Vars

Posted: Thu Nov 09, 2006 1:27 am
by 4Boredom
Im looking to post a database value into a textbox and its not working.

Code: Select all

<textarea name="a1" id="a1" cols="30" rows="4" value=<?php echo $a1 ?>></textarea>
however.... it works in this

Code: Select all

<input name=username type=text id=username value=<?php echo $a1 ?>>

Re: Posting DB Vars

Posted: Thu Nov 09, 2006 1:32 am
by Luke

Code: Select all

<textarea name="a1" id="a1" cols="30" rows="4"><?php echo $a1; ?></textarea>

Posted: Thu Nov 09, 2006 1:38 am
by 4Boredom
thank you

Posted: Thu Nov 09, 2006 6:31 am
by Mordred
Also, you need two other considerations:

Code: Select all

<input name=username type=text id=username value=<?php echo $a1 ?>>

1. Use quotes in the HTML, or you'll have problems

Code: Select all

<input name="username" type="text" id="username" value="<?php echo $a1 ?>">
2. Escape variables before outputting them to HTML or you'll have problems

Code: Select all

<input name="username" type="text" id="username" value="<?php echo htmlentities($a1, ENT_QUOTES, "utf-8") ?>">
(adjust the params to your system, but don't omit them, or you'll ... you guessed right: have problems :) )