简体   繁体   English

如何从html内联表单发布用户名

[英]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 嘿,我有一个要发布的表单,如何使用drupal变量发送用户名

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

How can I change the value to be the user name using the drupal variables? 如何使用drupal变量将值更改为用户名?

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: 并在Submit函数中获得如下代码:

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

If you need to describe input in html you can get it in submit function by simple: 如果您需要用html描述输入,则可以通过简单的方式在Submit函数中获取它:

$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');

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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