簡體   English   中英

HTML 表單提交問題

[英]Problem with HTML form submit

誰能告訴我為什么這個表單不能正確地向服務器提交值?

  <form method="post" action="http://www.***.com/index.php/session/authenticate" class="form login" id="login_form"> 
    <div class="group wat-cf"> 
      <div class="left"> 
        <label class="label right">Login</label> 
      </div> 
      <div class="right"> 
        <input type="text" class="text_field" id="username"/> 
      </div> 
    </div> 
    <div class="group wat-cf"> 
      <div class="left"> 
        <label class="label right">Password</label> 
      </div> 
      <div class="right"> 
        <input type="password" class="text_field" id="password"/> 
      </div> 
    </div> 
    <div class="group navform wat-cf"> 
      <div class="right"> 
        <button class="button" type="submit"> 
          <img src="images/icons/key.png" alt="Save" /> Login
        </button> 
      </div> 
    </div> 
  </form> 

在服務器端,我回顯了$_POST超全局變量,它是空的,我可以看到提交表單時發送的請求標頭:

Accept:text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Charset:ISO-8859-1,utf-8;q=0.7,*;q=0.3
Accept-Encoding:gzip,deflate,sdch
Accept-Language:en-US,en;q=0.8
Cache-Control:max-age=0
Connection:keep-alive
Content-Length:0
Content-Type:application/x-www-form-urlencoded
Cookie:ci_session=***session_id=***user_agent%22%3Bs%3A50%3A%22Mozilla%2F5.0+%28Macintosh%3B+Intel+Mac+OS+X+10_6_7%29+App%22%3Bs%3A13%3A%22last_activity%22%3Bi%3A1307578661%3B%7D31ee24db2875550081268dc7df883f76; ci_csrf_token=***
Host:www.***.com
Origin:http://**.com
Referer:http://***.com/index.php/session/login
User-Agent:Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_7) AppleWebKit/534.30 (KHTML, like Gecko) Chrome/*** Safari/534.30

你忘了給輸入類型的名字,像這樣

<input type="text" class="text_field" name="username" id="username"/> 

<input type="password" class="text_field" name="password" id="password"/> 

input的標簽沒有name屬性。 我認為您使用的是id而不是name

例如

<input type="text" class="text_field" id="username"/>

應該

<input type="text" class="text_field" id="username" name="username" />

或者干脆

<input type="text" class="text_field" name="username"/>

如果您沒有將id用於其他任何事情。

它是表單上提交的輸入元素的名稱屬性。 使用 name='username' 等。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM