21

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?

1 Answer 1

53

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

<input type="text" name="username" />
2
  • I was having the same issue using Boot Strap login form elements (type="email", type="password"). This answer is a saviour ! Commented Dec 25, 2018 at 21:14
  • Old but gold! Thank you so much.
    – CaTx
    Commented Jan 30, 2023 at 11:16

Your Answer

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

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