2

I'm using the following code to do a simple login in php.I have set an action to test.php but nothing happens when the login button is clicked.

    <div class="limiter">
        <div class="container-login100" style="background-image: url('images/bg-01.jpg');">
            <div class="wrap-login100">
                <form class="login100-form validate-form" action="test.php">
                    <span class="login100-form-logo">
                        <i class="zmdi zmdi-landscape"></i>
                    </span>

                    <span class="login100-form-title p-b-34 p-t-27">
                        Log in
                    </span>

                    <div class="wrap-input100 validate-input" data-validate = "Enter username">
                        <input class="input100" type="text" name="username" placeholder="Username">
                        <span class="focus-input100" data-placeholder="&#xf207;"></span>
                    </div>

                    <div class="wrap-input100 validate-input" data-validate="Enter password">
                        <input class="input100" type="password" name="pass" placeholder="Password">
                        <span class="focus-input100" data-placeholder="&#xf191;"></span>
                    </div>

                    <div class="contact100-form-checkbox">
                        <input class="input-checkbox100" id="ckb1" type="checkbox" name="remember-me">
                        <label class="label-checkbox100" for="ckb1">
                            Remember me
                        </label>
                    </div>

                    <div class="container-login100-form-btn">
                        <button class="login100-form-btn">
                            Login
                        </button>
                    </div>

                    <div class="text-center p-t-90">
                        <a class="txt1" href="#">
                            Forgot Password?
                        </a>
                    </div>
                </form>
            </div>
        </div>
    </div>
9
  • 1
    change <button class="login100-form-btn">Login</button> to <button class="login100-form-btn" type="submit">Login</button> Commented Feb 20, 2019 at 8:59
  • 1
    You should also post the contents of the test.php file as well Commented Feb 20, 2019 at 9:01
  • 1
    @MasivuyeCokile I thought that but according to this and this the default for a button is submit if its inside a form! Go figure Commented Feb 20, 2019 at 9:01
  • 1
    @MasivuyeCokile That fixed the issue :) Thanks Commented Feb 20, 2019 at 9:02
  • 1
    @MasivuyeCokile Ok, just read your first comment :) Commented Feb 20, 2019 at 9:07

1 Answer 1

1

Change

<button class="login100-form-btn">Login</button>

To

<button class="login100-form-btn" type="submit">Login</button>

And also add a method attribute to your form.

<form class="login100-form validate-form" action="test.php">

to look

<form class="login100-form validate-form" action="test.php" method="POST">

Then on your test.php side use $_POST

Sign up to request clarification or add additional context in comments.

1 Comment

Adding type="submit" is not necessary. "Submit" is the default type for a button inside a form where the attribute is not specified. Documentation. And here's a demo of the OP's original code: jsfiddle.net/agjcyz0L You can see that clicking the Login button causes the form to submit, without the "type" attribute being needed. If OP is saying that nothing is happening, then possibly they have some other issue. Either that or they are not describing the problem very clearly.

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.