Author Topic: prefill html form text field with php variable  (Read 4915 times)

0 Members and 1 Guest are viewing this topic.

Offline steveeyes

  • Full Member
  • ***
  • Posts: 177
    • View Profile
prefill html form text field with php variable
« on: October 17, 2006, 05:10:54 PM »
I need someone smart with PHP that can show me the way.

I created a simple HTML form in the detail.html template. I have a text field that says:

<input name="username" type="text" id="username">

Is there a way to prefill a HTML form text field with a php variable (I hope I'm using the right terms). In this case, 4images variable is "image_name".

In other words, I'm trying to use the image_name variable to prefill a text field. The form is an html form. Right now the user has to type in the username, but it would be nice if this could be prefilled.

I just don't know how to use php with html to make this happen. I did a google search and found this:

<td colspan="2"><input type="text" name="username" value="<?=$_POST['image_name']?>" id="username">*</td>


But it didn't work. The person still had to type in the image_name (for our members they call this username).


Any help would be appreciated.

thanks
steve

Offline steveeyes

  • Full Member
  • ***
  • Posts: 177
    • View Profile
Re: prefill html form text field with php variable
« Reply #1 on: October 17, 2006, 10:20:09 PM »
oK........can close this....got it to work....here is the solution if anyone else is doing this:

<input type="text" name="username" value="{image_name}" id="username">