1

Can anyone tell me why this form does not properly submit values to server?

 <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> 

On the server side I echo out the $_POST superglobal which is empty, and I can see my request headers which are sent when the form is submitted:

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 
6
  • Does the HTML validate? Could there be two nested forms? Commented Jun 9, 2011 at 0:30
  • sure about that action url ?? Commented Jun 9, 2011 at 0:30
  • Do you var_dump $_POST or $_POST['']? Because that looks correct. Also, you should use var_dump or print_r as the $_POST is an array Commented Jun 9, 2011 at 0:31
  • I'm just commenting out the action url for security purposes, the actual form has the proper action url which is confirmed by the output from my php script on the server Commented Jun 9, 2011 at 0:31
  • insecure to give us the url of a site on the internet, there must be a lot of insure sits out there then :-) Commented Jun 9, 2011 at 0:33

3 Answers 3

11

You forgot to give the name for the input type, like this

<input type="text" class="text_field" name="username" id="username"/> <input type="password" class="text_field" name="password" id="password"/> 
Sign up to request clarification or add additional context in comments.

4 Comments

I thought using 'name' was deprecated in favor of 'id'?
No, they are both used. Name is for the server (the actual name of the field), id is used for CSS. The ID is not sent to the server
name is not deprecated for form elements.
name is only deprecated for most elements outside of form elements, and on form itself. It is not deprecated for input elements and the like.
1

You input tags have no name attribute. I think you are using id's instead of name's

For instance

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

should be

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

or simply

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

if you are not using the id's for anything else.

Comments

1

It's the name attribute of input elements that's submitted on the form. Use name='username', etc.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.