title: Page is just being refreshed when i try to add data. mysqli_stmt_close() expects parameter 1 to be mysqli_stmt
body: <p>I am having a trouble when i try to add a data to MySQL  database. I click the submit button and nothing happens just the page is being refreshed. </p>
  
  <p>The following error occurs:</p>
  
  <blockquote>
    <p>Warning: mysqli_stmt_close() expects parameter 1 to be mysqli_stmt, bool given in C:\xampp\htdocs\loginsystm\register.php on line 92</p>
  </blockquote>
  
  <p>Here's my PHP code:</p>
  
  <pre><code>    if(empty($name) &amp;&amp; empty($password) &amp;&amp; empty($confirm_password) &amp;&amp; empty($thirdName) &amp;&amp; empty($phone) &amp;&amp; empty($email)){
  
      // Prepare an insert statement
      $sql = "INSERT INTO users (username, thirdName, email, phone, age, password) VALUES ('$name', '$password', '$thirdName','$email','$phone')";
      if($stmt = mysqli_prepare($conn,$sql)){
          // Bind variables to the prepared statement as parameters
          mysqli_stmt_bind_param($stmt, "sssss", $name, $password, $thirdName,$email,$phone);
  
          // Set parameters
          $param_name = $name;
          $param_thirdName = $thirdName;
          $param_email = $email;
          $param_phone = $phone;
          $param_password = password_hash($password, PASSWORD_DEFAULT); // Creates a password hash
  
          // Attempt to execute the prepared statement
          if(mysqli_stmt_execute($stmt)){
              // Redirect to login page
              header("location: login.php");
          } else{
              echo "Something went wrong. Please try again later.";
          }
      }
  
      // Close statement
      mysqli_stmt_close($stmt);
  }
  </code></pre>
  
  <p>And here is my HTML </p>
  
  <pre><code>       &lt;form action="&lt;?php echo htmlspecialchars($_SERVER["PHP_SELF"]); ?&gt;" method="post"&gt;
          &lt;div class="form-group &lt;?php echo (!empty($username_err)) ? 'has-error' : ''; ?&gt;"&gt;
              &lt;label&gt;Name&lt;/label&gt;
              &lt;input type="text" name="name" class="form-control" value="&lt;?php echo $name; ?&gt;"&gt;
              &lt;span class="help-block"&gt;&lt;?php echo $name_err; ?&gt;&lt;/span&gt;
          &lt;/div&gt;    
          &lt;div class="form-group &lt;?php echo (!empty($password_err)) ? 'has-error' : ''; ?&gt;"&gt;
              &lt;label&gt;Third Name&lt;/label&gt;
              &lt;input type="text" name="thirdName" class="form-control" value="&lt;?php echo $password; ?&gt;"&gt;
              &lt;span class="help-block"&gt;&lt;?php echo $password_err; ?&gt;&lt;/span&gt;
          &lt;/div&gt;
          &lt;div class="form-group &lt;?php echo (!empty($confirm_password_err)) ? 'has-error' : ''; ?&gt;"&gt;
              &lt;label&gt;Email&lt;/label&gt;
              &lt;input type="text" name="email" class="form-control" value="&lt;?php echo $confirm_password; ?&gt;"&gt;
              &lt;span class="help-block"&gt;&lt;?php echo $confirm_password_err; ?&gt;&lt;/span&gt;
          &lt;/div&gt;
          &lt;div class="form-group &lt;?php echo (!empty($confirm_password_err)) ? 'has-error' : ''; ?&gt;"&gt;
              &lt;label&gt;Phone number&lt;/label&gt;
              &lt;input type="text" name="phone" class="form-control" value="&lt;?php echo $confirm_password; ?&gt;"&gt;
              &lt;span class="help-block"&gt;&lt;?php echo $confirm_password_err; ?&gt;&lt;/span&gt;
          &lt;/div&gt;
          &lt;div class="form-group &lt;?php echo (!empty($confirm_password_err)) ? 'has-error' : ''; ?&gt;"&gt;
              &lt;label&gt;Password&lt;/label&gt;
              &lt;input type="password" name="password" class="form-control" value="&lt;?php echo $confirm_password; ?&gt;"&gt;
              &lt;span class="help-block"&gt;&lt;?php echo $confirm_password_err; ?&gt;&lt;/span&gt;
          &lt;/div&gt;
          &lt;div class="form-group &lt;?php echo (!empty($confirm_password_err)) ? 'has-error' : ''; ?&gt;"&gt;
              &lt;label&gt;Confirm Password&lt;/label&gt;
              &lt;input type="password" name="confirm_password" class="form-control" value="&lt;?php echo $confirm_password; ?&gt;"&gt;
              &lt;span class="help-block"&gt;&lt;?php echo $confirm_password_err; ?&gt;&lt;/span&gt;
          &lt;/div&gt;
          &lt;div class="form-group"&gt;
              &lt;input type="submit" class="btn btn-primary" value="Submit"&gt;
              &lt;input type="reset" class="btn btn-default" value="Reset"&gt;
          &lt;/div&gt;
          &lt;p&gt;Already have an account? &lt;a href="login.php"&gt;Login here&lt;/a&gt;.&lt;/p&gt;
      &lt;/form&gt;
  </code></pre>
  
  <p>I know my html looks so bad but i don't have the time to manage it i'm sorry.
  Thank you!</p>