如何从 Web2Py 中的表单提交中获取值

How do I get values from a form submission in Web2Py

我没有像我想的那样从 "request.vars" 或 "request.post_vars" 中提交的表单中获得价值。

这是我的 HTML 表格:

{{extend 'layout.html'}}
{{=message}}
<form id="LoginForm" name="FormLogin" action="{{URL()}}" method="post">
<div class="container">
        <div class="row">
        <div class="col-md-offset-5 col-md-3 col-sm-6">
        <div class="form-login">
            <h4>{{=T("Welcome")}}</h4>
            <input type="text" id="UserName" class="form-control input-sm chat-input" placeholder="{{=T("username")}}" />
            </br>
            <input type="text" id="UserPassword" class="form-control input-sm chat-input" placeholder="{{=T("password")}}" />
            </br>
            <div class="wrapper">
                <span class="group-btn">     
                    <button type="submit" class="btn btn-primary btn-md">{{=T("login")}} <i class="fa fa-sign-in"></i></button>
                </span>
                <span class="group-btn" style="float:right;">
                    <a href="{{=URL("prov_login", "register")}}" class="btn btn-success btn-md">{{=T("Register")}}</a>
                </span>
            </div>
        </div>

    </div>
</div>
</div>
</form>

我的控制器是这样的:

def index():
if request.vars>0:
    out_message = "Registration request received "
else:
    out_message = "no post"

return dict(message=out_message)

我错过了什么?为什么我没有得到输入值?

查看代码:

{{extend 'layout.html'}}
{{=message}}
<form>
    <div class="container">
        <div class="row">
            <div class="col-md-offset-5 col-md-3 col-sm-6">
                <div class="form-login">
                    <h4>{{=T("Welcome")}}</h4>
                    <input type="text" id="UserName" name="username" class="form-control input-sm chat-input" placeholder="{{=T("username")}}" />
                    </br>
                    <input type="text" id="UserPassword" name="password" class="form-control input-sm chat-input" placeholder="{{=T("password")}}" />
                    </br>
                    <div class="wrapper">
                        <span class="group-btn">     
                        <button type="submit" class="btn btn-primary btn-md">{{=T("login")}} <i class="fa fa-sign-in"></i></button>
                        </span>
                        <span class="group-btn" style="float:right;">
                            <a href="{{=URL("prov_login", "register")}}" class="btn btn-success btn-md">{{=T("Register")}}</a>
                        </span>
                    </div>
                </div>
            </div>
        </div>
    </div>
</form>

控制器代码:

def index():
    if request.vars>0:
        #out_message = "Registration request received"
# you can write this then you see all vars return after form submission
        out_message = request.vars 
    else:
        out_message = "no post"
    return dict(message=out_message)