2010-11-06 44 views
0

我有什么就可以了,但这种形式的页面:基本HTTP形式发布

<form method="post" action="/sign-in"> 
    <input type="text" id="username" /> 
    <input type="password" id="password" /> 
    <input type="submit" /> 
</form> 

输入值,“usernamed”和“密码”,当表单通过提交按钮提交,我得到后此HTTP标头:

POST http://localhost:12339/sign-in HTTP/1.1 
Host: localhost:12339 
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.12)... 
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 
Accept-Language: en-us,en;q=0.5 
Accept-Encoding: gzip,deflate 
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7 
Keep-Alive: 115 
Connection: keep-alive 
Referer: http://localhost:12339/ 
Cookie: Authorization=test 
Content-Type: application/x-www-form-urlencoded 
Content-Length: 0 

我的问题是,为什么不是“用户名”和“密码”表单字段值被张贴在HTTP发布的内容?

回答

3

发送表单数据时,将从name属性中检索名称,而不是从id中检索名称。试试这个:

<form method="post" action="/sign-in"> 
    <input type="text" name="username" /> 
    <input type="password" name="password" /> 
    <input type="submit" /> 
</form> 

或者,如果你需要的ID为别的东西:

<form method="post" action="/sign-in"> 
    <input type="text" id="username" name="username" /> 
    <input type="password" id="password" name="password" /> 
    <input type="submit" /> 
</form>