We're a community of 1077K IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,076,285 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

safe value in textarea

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>
6
Contributors
7
Replies
11 Hours
Discussion Span
5 Months Ago
Last Updated
8
Views
hwoarang69
Posting Pro
569 posts since Feb 2012
Reputation Points: 6
Solved Threads: 0
Skill Endorsements: 7

value attribute is not needed in textarea
use this instead

<textarea>
 <?php if(isset($_POST['description'])){echo htmlentities($_POST['description']);}?>
 </textarea>
code739
Posting Whiz in Training
208 posts since May 2012
Reputation Points: 17
Solved Threads: 28
Skill Endorsements: 5

<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

<textarea>
<?
   // plcae your data here
?>
</textarea>
radhakrishna.p
Posting Whiz in Training
262 posts since Nov 2012
Reputation Points: 29
Solved Threads: 59
Skill Endorsements: 10

thats right =)

code739
Posting Whiz in Training
208 posts since May 2012
Reputation Points: 17
Solved Threads: 28
Skill Endorsements: 5

@adhakrishna.p Short hand tags is bad.

phorce
Master Poster
738 posts since Jul 2011
Reputation Points: 63
Solved Threads: 91
Skill Endorsements: 16
<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.

hwoarang69
Posting Pro
569 posts since Feb 2012
Reputation Points: 6
Solved Threads: 0
Skill Endorsements: 7

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

radhakrishna.p
Posting Whiz in Training
262 posts since Nov 2012
Reputation Points: 29
Solved Threads: 59
Skill Endorsements: 10

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

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

It has to go on one line:

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

Your code seems to be like the above though.

diafol
Keep Smiling
Moderator
10,666 posts since Oct 2006
Reputation Points: 1,628
Solved Threads: 1,514
Skill Endorsements: 57

This article has been dead for over three months: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
 
© 2013 DaniWeb® LLC
Page rendered in 0.1018 seconds using 2.72MB