Jump to content


This topic is now archived and is closed to further replies.


Displaying exactly what is in the field...*SOLVED*

Recommended Posts

I have a site where users can put a small picture as their username. There is an area where you can change your username, and a user can input something like:

<img src="image_URL" border=0>

And that exact information as they typed it will be submitted in the database in their 'username' field. The problem I am having is I have an input box that shows their current username, then they can highlight it and change it.
If the user has an image as their name, obviously the input box can only display text and not the image. I would like to make the input box display:

<img src="image_URL" border=0>

EXACTLY like that. How do I just select that from the db without it thinking I am trying to display an image in the input box? Here is the code I am using for the input box currently:

[code]<input type=text name="username" maxlength=255 length=20 value="$player[username]">[/code]

It is the value part that needs to be changed...

Any help would be appreciated. Thanks XD

Share this post

Link to post
Share on other sites
I think that this is what you want: http://sg.php.net/manual/en/function.htmlspecialchars.php

For example:

[code]$username_encoded = htmlspecialchars($player['username']);
print '<input type=text name="username" maxlength=255 length=20 value="' . $username_encoded. '">';[/code]

Share this post

Link to post
Share on other sites


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.