HTML form to submit

Can someone tell me why on earth this is not subject to itself?

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 press the submit button, I don’t see anything inside the POST array. What simple thing have I completely forgotten?

Thank!

+5
source share
5 answers

Besides the fact that your form element is missing attributes action.

Your inputs need name attributes:

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

it should be

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

Missing = sign.

You also miss 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" />
+8
source
  • equals ""
  • name .

<?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>
+4

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

.php

+2

<?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
}
?>
0

All Articles