8

Can someone tell me why on earth this is not submitting to self?

I have the following setup:

<?php
     print_r($_POST);
?>

 <form name="bizLoginForm" method="post" action"" >
    <table id="loginTable">
        <tr><td>Username:</td><td><input type="text" id="loginUsername" /></td></tr>
        <tr><td>Password:</td><td><input type="password" id="loginPassword" /></td></tr>
    </table>
    <input type="Submit" value="Login" />
</form>

and every time I click on the submit button i see nothing inside the POST array. What simple thing have I totally overlooked?

Thanks!

5 Answers 5

12

Aside from the fact the equals is missing from your action attribute in your form element.

Your inputs need name attributes:

<tr>
    <td>Username:</td>
    <td><input id="loginUsername" name="loginUsername" type="text" /></td>
</tr>
0
8
 <form name="bizLoginForm" method="post" action"" >

should be

 <form name="bizLoginForm" method="post" action="" >

Missing = sign.

You're also missing the name attribute inside your input tags, so change

<input type="text" id="loginUsername" />

and

<input type="password" id="loginPassword" />

to

<input type="text" id="loginUsername" name="loginUsername" />

and

<input type="password" id="loginPassword" name="loginPassword" />
5
  • :-) html needs a compiler maybe ?
    – sjobe
    Aug 17, 2012 at 16:56
  • Error or it's not submitting ?
    – sjobe
    Aug 17, 2012 at 16:58
  • ah, doensn't like the capital "S" in submit but that also doesn't seem to get the POST array seeing the data.
    – ackerchez
    Aug 17, 2012 at 17:01
  • 1
    see the suggestions below about adding a name attribute to everything. I missed that actually. No "name" attribute, no data will go through.
    – sjobe
    Aug 17, 2012 at 17:06
  • 1
    @sjobe: He's missing the name attribute. See Richard's answer above. Aug 17, 2012 at 18:40
4
  • You should add equals sign between action and ""
  • Also specify name attribute for each input field.

<?php
     print_r($_POST);
?>

 <form name="bizLoginForm" method="post" action="" >
    <table id="loginTable">
        <tr><td>Username:</td><td><input type="text" name="login" id="loginUsername" /></td></tr>
        <tr><td>Password:</td><td><input type="password" name="password" id="loginPassword" /></td></tr>
    </table>
    <input type="Submit" value="Login" /></form>
2

Try this

<?php
   if(isset($_POST['submit_button']))
      print_r($_POST);
?>

<form name="bizLoginForm" method="post" action"<?php echo $_SERVER['PHP_SELF']?>" >
  <table id="loginTable">
    <tr><td>Username:</td><td><input type="text" id="loginUsername" /></td></tr>
    <tr><td>Password:</td><td><input type="password" id="loginPassword" /></td></tr>
  </table>
  <input type="Submit" name="submit_button" value="Login" />
</form>

Save the file with .php extension

0

try this

<?php
if(isset($_GET["submitted"])){
    print_r($_POST["values"]);
} else {
?>
 <form name="bizLoginForm" method="post" action="?submitted" >
    <table id="loginTable">
        <tr><td>Username:</td><td><input type="text" name="values[]" id="loginUsername" /></td></tr>
        <tr><td>Password:</td><td><input type="password" name="values[]" id="loginPassword" /></td></tr>
    </table>
    <input type="Submit" value="Login" />
</form>
<?php
}
?>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.