Функция isset работает неправильно

Я пытаюсь вставить записи в таблицу, но у меня проблема с функцией isset . Я не могу обработать код.

В следующем коде оператор else выполняется вместо функции isset.

  <?php if (isset($_POST['submit'])) { include_once 'dbh.inc.php'; $firstname = mysqli_real_escape_string($conn, $_POST['firstname']); $surname = mysqli_real_escape_string($conn, $_POST['surname']); $email = mysqli_real_escape_string($conn, $_POST['email']); $username = mysqli_real_escape_string($conn, $_POST['username']); $password = mysqli_real_escape_string($conn, $_POST['password']); $cpassword = mysqli_real_escape_string($conn, $_POST['cpassword']); $bdate = mysqli_real_escape_string($conn, $_POST['bdate']); $gender = mysqli_real_escape_string($conn, $_POST['gender']); if(empty($firstname) || empty($surname) || empty($email) || empty($username) || empty($password) || empty($cpassword) || empty($bdate) || empty($gender)) { header("Location: ../index.php?index=empty"); exit(); } else { $sql = "SELECT * FROM users WHERE username='$username'"; $result = mysqli_query($conn,$sql); $resultCheck = mysqli_num_rows($result); if ($resultCheck > 0) { header("Location: ../index.php?index=username already taken"); exit(); } else { // Hashing the password $hashedPassword = password_hash($password, PASSWORD_DEFAULT); //Insert users into the database $sql = "INSERT INTO users (id, firstname, surname, email, username, password, bdate, gender) VALUES ('', '$firstname', '$surname', '$email', '$username', '$password', '$bdate', '$gender');"; mysqli_query($conn, $sql); header("Location: ../profile.php"); exit(); } } } else { header("Location: ../index.php?index=error"); exit(); } 

Вот внешний интерфейс, содержащий часть «зарегистрироваться»:

 <div class="container and"> <div class="row"> <div class="col-lg-6 pull-right"> <div class="panel panel-default"> <div class="panel-heading"> <h3>Create a new account.</h3> </div> <div class="panel-body"> <form id="loginform" action="includes/signup.inc.php" method="POST"> <div class="row"> <div class="form-group has-error col-md-6"> <input type="text" class="form-control" name="firstname" placeholder="First Name"> </div> <div class="form-group has-error col-md-6"> <input type="text" class="form-control" name="surname" placeholder="Surname"> </div> </div> <div class="row padding-top-10"> <div class="form-group has-error col-md-12"> <input type="text" class="form-control" name="email" placeholder="Email Address"> </div> </div> <div class="row padding-top-10"> <div class="form-group has-error col-md-12"> <input type="text" class="form-control" name="username" placeholder="Username"> </div> </div> <div class="row padding-top-10"> <div class="form-group has-error col-md-12 padding-top-10"> <input type="password" class="form-control" name="password" placeholder="Password"> </div> </div> <div class="row padding-top-10"> <div class="form-group has-error col-md-12"> <input type="password" class="form-control" name="cpassword" placeholder="Confirm Password"> </div> </div> <div class="row padding-top-10"> <div class="form-group has-error col-md-12"> <h4>&nbsp;&nbsp; Birthday</h4> <input type="date" class="form-control" name="bdate" value="birthdate"> </div> </div> <div class="row padding-top-10"> <div class="form-group has-error col-md-6 padding-top-10"> <div class="pull-right"> Male: <input type="radio" name="gender" value="male" /> </div> </div> <div class=" form-group has-error col-md-6 padding-top-10"> Female: <input type="radio" name="gender" value="female"> </div> </div> <div class="padding-top-10"> <button class="btn btn-success" name="submit">Create Account</button> </div> </form> </div> </div> </div> </div> </div>