Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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!

like image 818
ackerchez Avatar asked Aug 17 '12 16:08

ackerchez


People also ask

How do you create a submission form in HTML?

The <input type="submit"> defines a button for submitting the form data to a form-handler. The form-handler is typically a file on the server with a script for processing input data. The form-handler is specified in the form's action attribute.

What is a self submitting form?

<br> <input type="submit" name="submit" value="Submit"> </form>

How can submit form to itself in PHP?

The proper way would be to use $_SERVER["PHP_SELF"] (in conjunction with htmlspecialchars to avoid possible exploits). You can also just skip the action= part empty, which is not W3C valid, but currently works in most (all?) browsers - the default is to submit to self if it's empty.

How do I automatically submit a form without clicking?

Submit a Form Using JavaScript The most simple way to submit a form without the submit button is to trigger the submit event of a form using JavaScript. In the below example we are going to create a function to submit a form. We will set that function at onclick event of a div tag.


1 Answers

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>
like image 127
Richard M Avatar answered Sep 30 '22 19:09

Richard M