SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Zealot bensheard's Avatar
    Join Date
    Jun 2006
    Location
    Cape Town | South Africa
    Posts
    117
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Default values in input textboxes

    Hello,
    This is also linked to php so I will ask in that forum as well, but I thought i might find the answer here. I have a website with a logging in function, and on the user's control panel, he/she can change the personal details. SO when the user goes onto that page, I get the users current info form a database and then I have a text box like this:
    Code:
     
    <?php
    echo "<input type = 'text' value = $users_current_name >";
    ?>
    But if in the beginning the user entered his first and second name with a space between, eg. Ben Sheard, in this textbox it only displays "Ben" but not the surname. Can someone help me?
    Thanks
    Ben Sheard
    -------------
    Log all your dives easily and quickly from anywhere in the world
    www.divinglogs.cafe150.com

  2. #2
    He's No Good To Me Dead silver trophybronze trophy stymiee's Avatar
    Join Date
    Feb 2003
    Location
    Slave I
    Posts
    23,423
    Mentioned
    2 Post(s)
    Tagged
    1 Thread(s)
    value ="$users_current_name">

    You forgot your quotes.

  3. #3
    SitePoint Author silver trophybronze trophy

    Join Date
    Nov 2004
    Location
    Ankh-Morpork
    Posts
    12,158
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You need single quotes (or escape the inner double quotes) in your echo statement:
    PHP Code:
    echo "<input type = 'text' value ='$users_current_name'>"
    Birnam wood is come to Dunsinane

  4. #4
    Non-Member lostseed's Avatar
    Join Date
    Sep 2005
    Location
    Zurconion Soon!
    Posts
    1,549
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    <?php
    echo "<input type = \"text\" value = \"$users_current_name\" >";
    ?>
    Why are you using a space before and after the = ?
    Is it just for readability?

    You can safely get away with:
    PHP Code:
    <?php
    echo "<input type=\"text\" value=\"$users_current_name\" >";
    ?>


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
  •