Jump to content

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


pocobueno1388

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
Link to comment
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]
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.