简体   繁体   中英

How to post username from html inline form

Hey I have a form I am posting, how can I send the user name using the drupal variables

 <input type="hidden" name="user[name]" value="user"/>

How can I change the value to be the user name using the drupal variables?

thanks

I dont quite get what you are trying to do.

If you want it to be in form variables you have to describe them in a form and submit it properly:

$form['user'] = array(
    '#type' => 'hidden',
    '#value' => 'user',
);

And get it like this in submit function:

$user = $form_state['values']['user'];

If you need to describe input in html you can get it in submit function by simple:

$user=$_POST['user'];

Maybe you want to use:

variable_set('user', $user);

it stores variable in sessions or something and you can access it in any place in your page by:

$user = variable_get('user');

it is deleted by:

variable_del('user');

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM