Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HTML form not sending parameters

Tags:

html

forms

I wrote a login panel for my website and everything looks fine but when I click on submit page refreshes and no parameters are being sent. I checked both get andpost methods but it's not working. here is my code:

<form id="login_form" action="index.php?task=login" method="post">
    <div class="control-group">
        <div class="controls">
            <div class="input-prepend">
                <span class="add-on"><i class="icon-user"></i></span>
                <input class="span2" id="username" type="text" value="Username" onblur="if(this.value=='') this.value='Username'" onfocus="if(this.value=='Username') this.value='';">
            </div>
        </div>
    </div>
    <div class="control-group">
        <div class="controls">
            <div class="input-prepend">
                <span class="add-on"><i class="icon-cog"></i></span>
                <input class="span2" id="password" type="password" value="Password" onblur="if(this.value=='') this.value='Password'" onfocus="if(this.value=='Password') this.value='';" />
            </div>
        </div>
    </div>
    <div class="clear"></div>
    <div class="separator"></div>
    <button type="submit" class="btn">Login</button>
</form>

Can anyone tell me what is wrong with my code?

like image 215
Farid Rn Avatar asked Oct 04 '12 18:10

Farid Rn


People also ask

Why form is not working in HTML?

Reasons Why HTML Required Not Working. As per the general rule, any HTML form control with the required attribute must have a value for successful submission. So if there is any field with a null value, it will prevent the form from being submitted in browsers that support constraint validation.

How do you get information from a form that is submitted using the GET method?

The Correct Answer is " Request.

How can I send form data in POST request?

To post HTML form data to the server in URL-encoded format, you need to make an HTTP POST request to the server and provide the HTML form data in the body of the POST message. You also need to specify the data type using the Content-Type: application/x-www-form-urlencoded request header.


1 Answers

Your input tags don't have the name attribute which is required to post the value.

<input type="text" name="username" />
like image 56
Lkrups Avatar answered Oct 05 '22 11:10

Lkrups