Sending form POST request to PHP

前端 未结 2 1401
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-01-26 16:22

I want to send a couple of form fields as a POST request to my PHP page, but I can\'t get it to work. Here is my code:

PHP login.php



        
相关标签:
2条回答
  • 2021-01-26 16:44

    Your inputs do not have names. The id is used for client-side referencing, but it is the (non-unique) name attribute that is used to determine the key for a value when the data is submitted. A form control cannot be successful (i.e. in the form data) without a name.

    0 讨论(0)
  • 2021-01-26 16:51

    You haven't included the name attribute in your html input elements. name attribute is used when passing form information to the webserver. id is primarily used for javascript based manipulation.

    Username<input type="text" name="username"/>
    Password<input type="password" name="password"/>
    
    0 讨论(0)
提交回复
热议问题