Jump to content


Photo

Auto fill the username in an form, how?

get username form

  • Please log in to reply
2 replies to this topic

#1 tommy1

tommy1

    Newbie

  • New Members
  • Pip
  • 1 posts

Posted 27 October 2013 - 12:38 PM

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!

 

),
'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 Ch0cu3r

Ch0cu3r

    Advanced Member

  • Moderators
  • 1,716 posts

Posted 28 October 2013 - 04:44 AM

Have you tried changing  'value' => $sDefaultTitle, to    'value' => getUsername(),



#3 KaiSheng

KaiSheng

    Advanced Member

  • Members
  • PipPipPip
  • 80 posts
  • LocationSinagpore
  • Age:20

Posted 11 November 2013 - 11:57 PM

simple, 

just do this.

 

Username:<input type="text"  name="username" size="17" value="<?php echo $row['username']; ?>" readonly="readonly"  >
 
 
be sure to do this before that code.
            <?php 
            
 
        //match the username and password entered with database record
        $query = ("SELECT id,role,username FROM `users` WHERE id='".$_SESSION['user_id']."'");
        $result = mysqli_query($link, $query) or die(mysqli_error($link));
            $row = mysqli_fetch_array($result);
            $_SESSION['user_id']= $row['id'];
            $_SESSION['username'] = $row['username'];
            
            ?>

Edited by KaiSheng, 12 November 2013 - 12:00 AM.





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

Cheap Linux VPS from $5
SSD Storage, 30 day Guarantee
1 TB of BW, 100% Network Uptime

AlphaBit.com