ackerchez
ackerchez

Reputation: 1744

HTML Form Submit To Self

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!

Upvotes: 8

Views: 54310

Answers (5)

Richard M
Richard M

Reputation: 14535

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>

Upvotes: 12

alsahin
alsahin

Reputation: 1

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

Upvotes: 0

Pradeep
Pradeep

Reputation: 416

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

Upvotes: 2

sjobe
sjobe

Reputation: 2837

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

Upvotes: 8

mintobit
mintobit

Reputation: 2383

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

Upvotes: 4

Related Questions