i am trying to save value inside input files. code below works fine when i use input field

<input type="text" name="price"
     value="<?php if(isset($_POST['price'])){echo htmlentities($_POST['price']);}?>" />

but when i do same thing inside testarea it dooesnt safe the value. any idea why its dont safe it?

<textarea type="text" name="description" 
         value="<?php if(isset($_POST['description'])){echo htmlentities($_POST['description']);}?>"></textarea>
4 Years
Discussion Span
Last Post by diafol

value attribute is not needed in textarea
use this instead

 <?php if(isset($_POST['description'])){echo htmlentities($_POST['description']);}?>

<textarea> tag does not have value attribute

if you want to place atext inside test area then you have to plcae your code as follows

   // plcae your data here

Edited by radhakrishna.p: for clarity to the solution

<textarea type="text" placeholder="Enter Description" name="description" id="description" class="field" rows="8"><?php if(isset($_POST['description'])){echo htmlentities($_POST['description']);}?</textarea>

i did this but placeholder is not showing up also it puts alot of spaceing in textarea.
should i tried to remove the spacing by using php or css? or is there a better way.

Edited by hwoarang69


i think use trim() function before you plcaing the data into text area

and one more thing you have applied some css class to text area element

check that class css once

is there any propery which gives those spacess in your textarea?

let me know the status once you modifies your code


Spaces in a textarea can often occur if you have something like the following:

    <?php echo "me";?>

It has to go on one line:

<textarea><?php echo "me";?></textarea>

Your code seems to be like the above though.

This article has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.