It is a login form:
<form action="login.php" method="post">
<div class="input-field">
<input type="text" name="email" placeholder="Email">
<i class="fa-solid fa-envelope icon"></i>
</div>
<div class="input-field">
<input type="password" name="password" id="password" placeholder="Password">
<i class="fa-solid fa-lock icon"></i>
<i class="fa-solid fa-eye-slash showHidePw ic" id="togglePassword" onclick="showIcon()" style="display: block"></i>
<i class="fa-solid fa-eye showHidePw ic" id="eye" style="display:none" onclick="showIcon()"></i>
</div>
<div class="checkbox-text">
<div class="checkbox-content">
<input type="checkbox" id="logCheck">
<label for="logCheck" class="text">Remember me</label>
</div>
<a href="#" class="text">Forgot password?</a>
</div>
<div class="input-field button">
<input type="submit" name="login-btn" value="Login">
</div>
</form>
PHP code:
if (isset($_POST['login-btn'])) {
dd($_POST);
}
The input submit does not work. When I click onto the button, nothing happens. I do not need to show you the real code, because also like this, it doesn't show anything. It is weird because the structure is the same of the the signup form, which, instead, works...
I hope someone can help me. Thanks
Edit:
this is the signup form (and the whole php code):
<form action="signup.php" method="post">
<div class="input-field signup">
<input type="text" value="<?php echo $name; ?>" placeholder="Name" name="name">
<i class="fa-solid fa-user icon"></i>
</div>
<div class="input-field signup">
<input type="text" value="<?php echo $lastname; ?>" placeholder="Last Name" name="lastname">
<i class="fa-solid fa-user icon"></i>
</div>
<div class="input-field signup">
<input type="text" value="<?php echo $email; ?>" placeholder="Email" name="email">
<i class="fa-solid fa-envelope icon"></i>
</div>
<div class="input-field signup">
<input type="password" value="<?php echo $password; ?>" class="password" name="password" placeholder="Password" id="password">
<i class="fa-solid fa-lock icon"></i>
</div>
<div class="input-field signup">
<input type="password" value="<?php echo $passwordConf; ?>" id="password" name="passwordConf" placeholder="Repeat Password">
<i class="fa-solid fa-lock icon"></i>
</div>
<div class="input-field button signup">
<input type="submit" name="register-btn" value="Sign Up">
</div>
</form>
PHP:
<?php
include(ROOT_PATH . "/app/database/db.php");
include(ROOT_PATH . "/app/helpers/validateUser.php");
$errors = array();
$name = '';
$lastname = '';
$email = '';
$password = '';
$passwordConf = '';
if (isset($_POST['register-btn'])) {
$errors = validateUser($_POST);
if (count($errors) === 0) {
unset($_POST['register-btn'], $_POST['passwordConf']);
$_POST['admin'] = 0;
$_POST['password'] = password_hash($_POST['password'], PASSWORD_DEFAULT);
$user_id = create('users', $_POST);
$user = selectOne('users', ['id' => $user_id]);
// log user in
$_SESSION['id'] = $user['id'];
$_SESSION['name'] = $user['name'];
$_SESSION['admin'] = $user['admin'];
$_SESSION['message'] = 'Login successful!';
$_SESSION['type'] = 'success';
if ($_SESSION['admin']) {
header('location: ' . BASE_URL . 'admin/dashboard.php');
} else {
header('location: ' . BASE_URL . '/index.php');
}
exit();
} else {
$name = $_POST['name'];
$lastname = $_POST['lastname'];
$email = $_POST['email'];
$password = $_POST['password'];
$passwordConf = $_POST['passwordConf'];
}
}
if (isset($_POST['login-btn'])) {
dd($_POST);
}