Reputation:
I have a form which i am using to update adds on my site, I am filling input value with existing adds but there is a problem in form it is showing adds images instead of text value.
I need to update adds link by replacing the link value in input field.
Input field has value as
<input name="addtop" type="text" value="<a href="http://www.xxyy.com/4g...." target="_blank" <img src="http://www.xxyy.com/h4...."/></a>" />
when i try to load page it shows image in input field instead of text as:
<a href="http://www.xxyy.com/4g...." target="_blank" <img src="http://www.xxyy.com/h4...."/> ></a>`
Please see how can I make input to show links in value instead of images.
Upvotes: 0
Views: 120
Reputation: 26074
You should use htmlspecialchars
for whatever sets the value=
of those <input type="text">
boxes.
It will take image tags and HTML and render them as HTML entities that will safely be place in that text box.
Then when you want to process the contents of that for, just use html_entity_decode
to decode the HTML entities.
UPDATE: Your first attempt to fix this—shown in the comments—is this:
<input name="addtop" type="text" value="htmlspecialchars(<?php echo $addtop?>)" />
That is just incorrect. htmlspecialchars
is a PHP function. So you need to put it in the <?php … ?>
area. It should be:
<input name="addtop" type="text" value="<?php echo htmlspecialchars($addtop)?>" />
Upvotes: 2