Here is my simple form
“`
<form action=”login.php” method=’POST’>
<section class=”form-top”>
<img src=”assets/img/working.gif” alt=””>
</section>
<section class=”form-main” id=”form-login”>
<?php
if (isset($_POST[‘login-submit’])) {
$username = $_POST[‘inp-username’];
$password = $_POST[‘inp-password’];
echo $username;
echo $password;
$sql = “SELECT * FROM `admin_users` WHERE `Username`='”.$username.”‘ AND `Password`='”.$password.”‘”;
$result = mysqli_query($connection, $sql);
if (mysqli_num_rows($result) == 0) {
// No such user
echo ‘<label id=”error-messages” style=”text-align: center; color: red; margin: 0; font-size: 14px; margin-bottom: 15px;”> Не правильный логин или пароль</label>’;
} else {
set_username($username);
?>
<script type=”text/javascript”>
window.location = ‘dashboard.php’
</script>
<?php
exit;
}
}
?>
<label for=”inp-login”>Username:</label>
<input type=”text” id=”inp-username” placeholder=”[email protected]” name=”inp-username”>
<label for=”inp-password”>Password:</label>
<input type=”text” id=”inp-password” placeholder=”example123″ name=”inp-password”>
<label id=”error-messages” style=”text-align: center; color: red; margin: 0; font-size: 14px;”></label>
<button class=”submit-button”>
<input type=”submit” id=”login-submit” name=”login-submit” value=”Войти”>
</button>
</section>
</form>
When I am pressing the button with my mouse – works just fine! But If I use TAB to navigate through inputs and then go to submit button and press Enter, then the page gets refreshed as it should, but $_POST[‘inp-username’] is null…
Thank you!