tags:

views:

30

answers:

2

I have a text box like ,

<!--<input type="text"  maxlength="255" name="$key" value="<?php echo $value;?>"  />-->

$value is b'bbb"bbb

But it only shows b'bbb as value.Can any1 help ???

+3  A: 

Properly escape your data that should be displayed unparsed in HTML using htmlentities():

<input type="text"  maxlength="255" name="<?php echo htmlentities($key);?>" value="<?php echo htmlentities($value);?>"  />

The quote char (") is breaking your code. It could get more dangerous if you've a $value like "><script>alert("xss")</script> (it's called XSS and will pop up an alert box with "xss")

Lekensteyn
thnaks that worked
A: 

Obviously the " in your $value is breaking the html.

Try echo htmlspecialchars($value);

Damien