title: Registration Form not Redirecting
body: <p>I've been making this registration form with HTML, PHP, MYSQL.</p>
  
  <p>So the config is as below. When I fill in the form and submit the page just reloads. I can't figure out if I'm missing something with the PHP or HTML.</p>
  
  <p>I don't know what's happening.</p>
  
  <p><strong>Maybe you can spot the error...</strong></p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;?php
  if( $_SERVER['REQUEST_METHOD']=='POST'){
      include('includes/config.php');
  
      if( isset( 
          $_POST['submit'],
          $_POST['firstname'],
          $_POST['lastname'],
          $_POST['email'],
          $_POST['mobile'],
          $_POST['username'],
          $_POST['password'] 
      ) ){
  
          $firstname=$_POST['firstname'];
          $lastname=$_POST['lastname'];
          $email=$_POST['email'];
          $mobile=$_POST['mobile'];
          $username=$_POST['username'];
          $password=md5($_POST['password']);
  
          $sql ='insert into `users` 
              ( `firstname`, `lastname`, `email`, `mobile`, `username`, `password`, `status` ) 
                  values 
              ( :firstname, :lastname, :email, :mobile, :username, :password, 1)';
  
          $query=$dbh-&gt;prepare( $sql );
  
          if( $query ){
              $query-&gt;bindParam(':firstname', $firstname, PDO::PARAM_STR);
              $query-&gt;bindParam(':lastname', $lastname, PDO::PARAM_STR);
              $query-&gt;bindParam(':email', $email, PDO::PARAM_STR);
              $query-&gt;bindParam(':mobile', $mobile, PDO::PARAM_STR);
              $query-&gt;bindParam(':username', $username, PDO::PARAM_STR);
              $query-&gt;bindParam(':password', $password, PDO::PARAM_STR);
  
              $res=$query-&gt;execute();
  
              if( $res ){
                  $lastInsertId = $dbh-&gt;lastInsertId();
                  if($lastInsertId){
                      echo "&lt;script&gt;
                          alert('Registration Sucessfull!');
                          location.href='login.php';
                      &lt;/script&gt;";         
                  }else{
                      $error="Something went wrong. Please try again";
                  }
              }   
          }else{
              exit('Error: Failed to prepare SQL statement');
          }
      }
  }
  
  ?&gt;
  
    &lt;!DOCTYPE html&gt;
    &lt;html class="loading no-js" lang="en" data-textdirection="ltr"&gt;
    &lt;!-- BEGIN: Head--&gt;
  
    &lt;head&gt;
      &lt;meta http-equiv="Content-Type" content="text/html; charset=UTF-8"&gt;
      &lt;meta http-equiv="X-UA-Compatible" content="IE=edge"&gt;
      &lt;meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0, minimal-ui"&gt;
      &lt;meta name="description" content="Vuexy admin is super flexible, powerful, clean &amp;amp; modern responsive bootstrap 4 admin template with unlimited possibilities."&gt;
      &lt;meta name="keywords" content="admin template, Vuexy admin template, dashboard template, flat admin template, responsive admin template, web app"&gt;
      &lt;meta name="author" content="PIXINVENT"&gt;
      &lt;title&gt;Register Page - Vuexy - Bootstrap HTML admin template&lt;/title&gt;
      &lt;link rel="apple-touch-icon" href="assets/images/ico/apple-icon-120.png"&gt;
      &lt;link rel="shortcut icon" type="image/x-icon" href="assets/images/ico/favicon.ico"&gt;
      &lt;link href="https://fonts.googleapis.com/css?family=Montserrat:300,400,500,600" rel="stylesheet"&gt;
  
      &lt;!-- BEGIN: Vendor CSS--&gt;
      &lt;link rel="stylesheet" type="text/css" href="assets/vendors/css/vendors.min.css"&gt;
      &lt;link rel="stylesheet" type="text/css" href="assets/vendors/css/ui/prism.min.css"&gt;
      &lt;link rel="stylesheet" type="text/css" href="assets/vendors/css/file-uploaders/dropzone.min.css"&gt;
      &lt;!-- END: Vendor CSS--&gt;
  
      &lt;!-- BEGIN: Theme CSS--&gt;
      &lt;link rel="stylesheet" type="text/css" href="assets/css/bootstrap.css"&gt;
      &lt;link rel="stylesheet" type="text/css" href="assets/css/bootstrap-extended.css"&gt;
      &lt;link rel="stylesheet" type="text/css" href="assets/css/colors.css"&gt;
      &lt;link rel="stylesheet" type="text/css" href="assets/css/components.css"&gt;
      &lt;link rel="stylesheet" type="text/css" href="assets/css/themes/dark-layout.css"&gt;
      &lt;link rel="stylesheet" type="text/css" href="assets/css/themes/semi-dark-layout.css"&gt;
  
      &lt;!-- BEGIN: Page CSS--&gt;
      &lt;link rel="stylesheet" type="text/css" href="assets/css/core/menu/menu-types/horizontal-menu.css"&gt;
      &lt;link rel="stylesheet" type="text/css" href="assets/css/core/colors/palette-gradient.css"&gt;
      &lt;link rel="stylesheet" type="text/css" href="assets/css/pages/authentication.css"&gt;
      &lt;link rel="stylesheet" type="text/css" href="assets/css/plugins/file-uploaders/dropzone.css"&gt;
      &lt;!-- END: Page CSS--&gt;
  
      &lt;!-- BEGIN: Custom CSS--&gt;
      &lt;link rel="stylesheet" type="text/css" href="assets/assets/css/style.css"&gt;
      &lt;!-- END: Custom CSS--&gt;
  
    &lt;/head&gt;
    &lt;!-- END: Head--&gt;
  
    &lt;!-- BEGIN: Body--&gt;
  
    &lt;body class="horizontal-layout horizontal-menu 1-column  navbar-floating footer-static bg-full-screen-image  blank-page blank-page" data-open="hover" data-menu="horizontal-menu" data-col="1-column"&gt;
      &lt;!-- BEGIN: Content--&gt;
      &lt;div class="app-content content"&gt;
        &lt;div class="content-overlay"&gt;&lt;/div&gt;
        &lt;div class="header-navbar-shadow"&gt;&lt;/div&gt;
        &lt;div class="content-wrapper"&gt;
          &lt;div class="content-header row"&gt;
          &lt;/div&gt;
          &lt;div class="content-body"&gt;
            &lt;section class="row flexbox-container" id="dropzone-examples"&gt;
              &lt;div class="col-xl-8 col-10 d-flex justify-content-center"&gt;
                &lt;div class="card bg-authentication rounded-0 mb-0"&gt;
                  &lt;div class="row m-0"&gt;
                    &lt;div class="col-lg-6 d-lg-block d-none text-center align-self-center pl-0 pr-3 py-0"&gt;
                      &lt;img src="assets/images/pages/register.jpg" alt="branding logo"&gt;
                    &lt;/div&gt;
                    &lt;div class="col-lg-6 col-12 p-0"&gt;
                      &lt;div class="card rounded-0 mb-0 p-2"&gt;
                        &lt;div class="card-header pt-50 pb-1"&gt;
                          &lt;div class="card-title"&gt;
                            &lt;h4 class="mb-0"&gt;Create Account&lt;/h4&gt;
                          &lt;/div&gt;
                        &lt;/div&gt;
                        &lt;p class="px-2"&gt;Fill the below form to create a new account.&lt;/p&gt;
                        &lt;div class="card-content"&gt;
                          &lt;div class="card-body pt-0"&gt;
                            &lt;form method="post" action="register.php" enctype="multipart/form-data" name="regform" onSubmit="return validate();" autocomplete="off"&gt;
  
                              &lt;div class="form-label-group"&gt;
                                &lt;input name="firstname" type="text" id="inputFirstname" class="form-control" placeholder="First Name" value="" required autocomplete="off"&gt;
                                &lt;label for="inputFirstname"&gt;First Name&lt;/label&gt;
                              &lt;/div&gt;
  
                              &lt;div class="form-label-group"&gt;
                                &lt;input name="lastname" type="text" id="inputLastname" class="form-control" placeholder="Last Name" value="" required autocomplete="off"&gt;
                                &lt;label for="inputLastname"&gt;Last Name&lt;/label&gt;
                              &lt;/div&gt;
  
                              &lt;div class="form-label-group"&gt;
                                &lt;input name="email" type="email" id="inputEmail" class="form-control" placeholder="Email" value="" required autocomplete="off"&gt;
                                &lt;label for="inputEmail"&gt;Email&lt;/label&gt;
                              &lt;/div&gt;
  
                              &lt;div class="form-label-group"&gt;
                                &lt;input name="mobile" type="tel" id="inputtel" class="form-control" placeholder="Phone Number" value="" required autocomplete="off"&gt;
                                &lt;label for="inputtel"&gt;Phone Number&lt;/label&gt;
                              &lt;/div&gt;
  
                              &lt;div class="form-label-group"&gt;
                                &lt;input name="username" type="text" id="inputUsername" class="form-control" placeholder="Username" value="" required autocomplete="off"&gt;
                                &lt;label for="inputUsername"&gt;Username&lt;/label&gt;
                              &lt;/div&gt;
  
                              &lt;div class="form-label-group"&gt;
                                &lt;input name="password" type="password" required pattern="(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{6,}" onchange="form.confirm_password.pattern = RegExp.escape(this.value);" id="inputPassword" class="form-control" placeholder="Password" value="" required autocomplete="off"
                                  data-toggle="tooltip" data-placement="right" title="Please use at least one number, one lowercase and one uppercase letter and it should be at least six characters that are letters, numbers or the underscore"&gt;
                                &lt;label for="inputPassword"&gt;Password&lt;/label&gt;
                              &lt;/div&gt;
  
                              &lt;div class="form-label-group"&gt;
                                &lt;input name="confirm_password" type="password" id="inputCPassword" class="form-control" placeholder="Confirm Password" value="" required autocomplete="off"&gt;
                                &lt;label for="inputCPassword"&gt;Confirm Password&lt;/label&gt;
                              &lt;/div&gt;
  
                              &lt;div class="form-label-group"&gt;
                                &lt;div class="form-group d-flex justify-content-between align-items-center"&gt;
                                  &lt;div class="text-left"&gt;
                                    &lt;fieldset class="checkbox"&gt;
                                      &lt;div class="vs-checkbox-con vs-checkbox-primary"&gt;
                                        &lt;input type="checkbox" name="terms" required&gt;
                                        &lt;span class="vs-checkbox"&gt;
                   &lt;span class="vs-checkbox--check"&gt;
                    &lt;i class="vs-icon feather icon-check"&gt;&lt;/i&gt;
                   &lt;/span&gt;
                                        &lt;/span&gt;
                                        &lt;span class=""&gt;I accept terms and conditions&lt;/span&gt;
                                      &lt;/div&gt;
                                    &lt;/fieldset&gt;
                                  &lt;/div&gt;
                                &lt;/div&gt;
                              &lt;/div&gt;
                              &lt;a href="login.php" class="btn btn-outline-primary float-left btn-inline mb-50"&gt;Login&lt;/a&gt;
                              &lt;button name="submit" type="submit" class="btn btn-primary float-right btn-inline mb-50"&gt;Register&lt;/button&gt;
                            &lt;/form&gt;
                          &lt;/div&gt;
                        &lt;/div&gt;
                      &lt;/div&gt;
                    &lt;/div&gt;
                  &lt;/div&gt;
                &lt;/div&gt;
              &lt;/div&gt;
            &lt;/section&gt;
  
          &lt;/div&gt;
        &lt;/div&gt;
      &lt;/div&gt;
      &lt;!-- END: Content--&gt;
  
  
  
      &lt;!-- BEGIN: Vendor JS--&gt;
      &lt;script src="assets/vendors/js/vendors.min.js"&gt;&lt;/script&gt;
      &lt;!-- BEGIN Vendor JS--&gt;
  
      &lt;!-- BEGIN: Page Vendor JS--&gt;
      &lt;script src="assets/vendors/js/ui/jquery.sticky.js"&gt;&lt;/script&gt;
      &lt;!-- END: Page Vendor JS--&gt;
  
      &lt;!-- BEGIN: Theme JS--&gt;
      &lt;script src="assets/js/core/app-menu.js"&gt;&lt;/script&gt;
      &lt;script src="assets/js/core/app.js"&gt;&lt;/script&gt;
      &lt;script src="assets/js/scripts/components.js"&gt;&lt;/script&gt;
      &lt;!-- END: Theme JS--&gt;
  
      &lt;!-- Loading Scripts --&gt;
      &lt;script src="js/jquery.min.js"&gt;&lt;/script&gt;
      &lt;script src="js/bootstrap-select.min.js"&gt;&lt;/script&gt;
      &lt;script src="js/bootstrap.min.js"&gt;&lt;/script&gt;
      &lt;script src="js/jquery.dataTables.min.js"&gt;&lt;/script&gt;
      &lt;script src="js/dataTables.bootstrap.min.js"&gt;&lt;/script&gt;
      &lt;script src="js/Chart.min.js"&gt;&lt;/script&gt;
      &lt;script src="js/fileinput.js"&gt;&lt;/script&gt;
      &lt;script src="js/chartData.js"&gt;&lt;/script&gt;
      &lt;script src="js/main.js"&gt;&lt;/script&gt;
  
    &lt;/body&gt;
    &lt;!-- END: Body--&gt;
  
    &lt;/html&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>I've been looking into this for a while and I can't seem to spot the error!</p>