Reputation: 348
have a problem with a form. In html I have a form which I want to submit via post, using enctype multipart/form-data. I used the code several times on other pages, but now it doesn't submit the data. No clue why. The following code comes from my script (it's not all, but the necessary part).
<?if ($_SERVER['REQUEST_METHOD'] == 'POST')
{
if (isset($_POST['login'])) {
require 'login.php';
}
elseif (isset($_POST['register'])) {
require 'register.php';
}
}
?>
<div id="login" role="form" class="r_form_elements" style="display:none">
<form class="form-signin bg-dark text-light" method="post" action="index2.php" enctype="multipart/form-data" autocomplete="off">
<div class="text-center mb-4">
<h1 class="h3 mb-3 font-weight-normal">Login</h1>
</div>
<div class="form-label-group mt-3">
<label for="inputEmail">Email address</label>
<input type="email" id="inputEmail" name="email" class="form-control" placeholder="Email address" required="" autofocus="">
</div>
<div class="form-label-group mt-3">
<label for="inputPassword">Password</label>
<input type="password" id="inputPassword" name="password" class="form-control" placeholder="Password" required="">
</div>
<label for="lang" style="display:none" class="sr-only">longitude</label>
<input type="text" style="display:none" name="lang" id="lang" class="form-control" required autofocus>
<label for="lat" style="display:none" class="sr-only">latitude</label>
<input type="text" style="display:none" name="lat" id="lat" class="form-control" required>
<button value="Login" name="login" class="btn btn-lg btn-primary btn-block mt-3" type="submit">Sign in</button>
<p class="mt-5 mb-3 text-muted text-center">By signing in you agree to the <a href="tos">Terms of Service</a></p>
</form>
</div>
This should normally submit data to the login-page. But it doesn't. There's simply no reaction or anything. As if the browser doesn't recognized the submit-button.
Can somebody explain the reason? I have tried different positions to be sure, but it doesn't help.
Thanks in advance.
Upvotes: 0
Views: 478
Reputation: 64727
Probably because you have two
<input type="text" ... style="display:none" required>
So when you submit, it sees that you have required inputs with no value, so it doesn't submit, and since you have display: none
you don't see the error message.
Upvotes: 3