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>
techno
  • 6,100
  • 16
  • 86
  • 192

1 Answers1

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

Bart
  • 527
  • 1
  • 7
  • 16
Masivuye Cokile
  • 4,754
  • 3
  • 19
  • 34
  • Adding `type="submit"` is not necessary. "Submit" is the default type for a button inside a form where the attribute is not specified. [Documentation](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button). And here's a demo of the OP's original code: https://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. – ADyson Feb 20 '19 at 09:18