SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Member Mustals's Avatar
    Join Date
    Oct 2000
    Location
    Bolton
    Posts
    16
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    A goldfish would probally know how to do this.

    I have looked eveywhere but am still unable to find the syntax to pass a PHP vaiable to a form field.
    All the searches come up with ways to get a variable and output some results on a web paged, database or email it and the books i have are no help with this.
    Mustals

  2. #2
    SitePoint Wizard samsm's Avatar
    Join Date
    Nov 2001
    Location
    Atlanta, GA, USA
    Posts
    5,011
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Take a look at this, see if it makes sence to you:

    <INPUT type='text' name ='groovetronic' value='<?php echo($variable); ?>'>

    See how that works? Is that what you are going for?
    Post again if I got it wrong or you need explanation.
    Using your unpaid time to add free content to SitePoint Pty Ltd's portfolio?

  3. #3
    SitePoint Enthusiast petersj's Avatar
    Join Date
    Aug 2002
    Posts
    59
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I guess you want to display some content in a text or text area field.

    PHP Code:
    echo'<input type="text" name="variableName" value="$variableName" size="20">'
    Or you might want to add the variable to a hidden field, this is an easy way to pass values from one page to the next if you have a long form spanning several pages.

    PHP Code:
    echo'<input type="hidden" name="variableName" value="$variableName">'

  4. #4
    SitePoint Member Mustals's Avatar
    Join Date
    Oct 2000
    Location
    Bolton
    Posts
    16
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Thanks Sam

    The format... value='<?php echo($variable); ?>' ...works really fine, it was no fun getting stuck on something like that.
    Thanks
    Mustals
    Last edited by Mustals; Oct 8, 2002 at 19:53.
    Mustals

  5. #5
    SitePoint Member FURY's Avatar
    Join Date
    Sep 2002
    Posts
    21
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    FYI

    PHP Code:
    echo'<input type="hidden" name="variableName" value="$variableName">'
    Will not work.. The signal quotes cancel the parsing of variables.

    The working version of that is

    PHP Code:
    echo'<input type="hidden" name="variableName" value="'.$variableName.'">'
    Mustals if you want a shorter version of what you are using now.. try
    PHP Code:
    <?=$variable=?>
    That will only work if some tag settings are on (default)..

  6. #6
    Mlle. Ledoyen silver trophy seanf's Avatar
    Join Date
    Jan 2001
    Location
    UK
    Posts
    7,168
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Moved to a more appropriate forum. The "Debug and Troubleshoot forum" is for problems with existing scripts

    Sean
    Harry Potter

    -- You lived inside my world so softly
    -- Protected only by the kindness of your nature


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •