SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Member
    Join Date
    Oct 2013
    Posts
    7
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Auto fill the username in an form, how?

    I need help with this. I have a form for add new users. But I don't want users to change the Title - I want to auto fill the username they have already. Right now it look like the picture. But I want to echo getUsername(); Any one can help me with this? Please!

    zmd3sy.png

    Here is my form code now. Any one? Please!

    Code PHP:
     ),
    'title' => array(
    'type' => 'text',
    'name' => 'title',
    'caption' => _t('_modzzz_model_form_caption_title'),
    'value' => $sDefaultTitle, 
    'required' => true,
    'checker' => array (
    'func' => 'length',
    'params' => array(3,$this->_oMain->_oConfig->getTitleLength()),
    'error' => _t ('_modzzz_model_form_err_title'),
    ),
    'db' => array (
    'pass' => 'Xss', 
    ),
    'display' => true,
    ),

  2. #2
    From Italy with love silver trophybronze trophy
    guido2004's Avatar
    Join Date
    Sep 2004
    Posts
    9,500
    Mentioned
    163 Post(s)
    Tagged
    4 Thread(s)
    The code you posted is just a piece of an array, and I guess you're using some kind of framework to create the form?

    Anyway, you might try to change this line
    PHP Code:
    'value' => $sDefaultTitle
    in
    PHP Code:
    'value' => getUsername(), 

  3. #3
    SitePoint Member BungeeBones's Avatar
    Join Date
    Jan 2008
    Location
    Florida
    Posts
    18
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If, after the form is filled with what you want, and you don't want them to be able to change it then make the input Readonly

    Code:
    <form action="demo_form.asp">
      Country: <input type="text" name="country" value="Norway" readonly><br>
      <input type="submit" value="Submit">
    </form>

    BungeeBones.com
    - A New Paradigm of Website Promotion

  4. #4
    SitePoint Member
    Join Date
    Oct 2013
    Posts
    7
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thaink you! This worked fine. It retrieves the user name now. but the user can still change the name. See the picture. Can I change so that they can not change the name now? I did tried to insert IF to this but i can't get it to work. I get error.


    nl6j53.png

    Quote Originally Posted by guido2004 View Post
    The code you posted is just a piece of an array, and I guess you're using some kind of framework to create the form?

    Anyway, you might try to change this line
    PHP Code:
    'value' => $sDefaultTitle
    in
    PHP Code:
    'value' => getUsername(), 

  5. #5
    SitePoint Member
    Join Date
    Oct 2013
    Posts
    7
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    My code look like this now. It working fine now. But they can change the username now. How can i input IF to this.

    ),
    'title' => array(
    'type' => 'text',
    'name' => 'title',
    'caption' => _t('_modzzz_model_form_caption_title'),
    'value' => getUsername(),
    'required' => true,
    'checker' => array (
    'func' => 'length',
    'params' => array(3,$this->_oMain->_oConfig->getTitleLength()),
    'error' => _t ('_modzzz_model_form_err_title'),
    ),
    'db' => array (
    'pass' => 'Xss',
    ),
    'display' => true,
    ),

  6. #6
    From Italy with love silver trophybronze trophy
    guido2004's Avatar
    Join Date
    Sep 2004
    Posts
    9,500
    Mentioned
    163 Post(s)
    Tagged
    4 Thread(s)
    I don't know if/how that is possible in the framework you're using


Tags for this Thread

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
  •