html - Reloading the page submitting the form twice using PHP -


recently started create simple website php , bootstrap 3 php pages header.php,footer.php , home.php. in header page have buttion named signup .upon clicking signup button pop modal (bootstrap modal) signup form.in home.php page included both header , footer php files.the problem code when click button modal open , form filled user .upon submitting form user registered , modal closed.but problem when refresh home page user again registering .so need reloading page after submitting modal form should not again submit user.can suggest me doing ..

this modal in header.php

       <div class="modal fade" id="mymodalnorm" tabindex="-1" role="dialog"     aria-labelledby="mymodallabel" aria-hidden="true">     <div class="modal-dialog modal-sm">         <div class="modal-content">             <!-- modal header -->             <div class="modal-header">                 <button type="button" class="close" data-dismiss="modal">                     <span aria-hidden="true">&times;</span> <span class="sr-only">close</span>                 </button>                 <h4 class="modal-title" id="mymodallabel">modal title</h4>             </div>              <!-- modal body -->             <div class="modal-body">                  <form class="form" role="form" method="post" action="home.php">                     <div class="form-group">                         <label for="exampleinputemail1">email address</label> <input                             type="email" class="form-control" id="exampleinputemail1"                             placeholder="enter email"  name="useremail" required=""/>                     </div>                     <div class="form-group">                         <label for="exampleinputusername1">username</label> <input                             type="text" class="form-control" id="exampleinputusername1"                             placeholder="enter username"  name="name" required=""/>                     </div>                     <div class="form-group">                         <label for="exampleinputpassword1">password</label> <input                             type="password" class="form-control" id="exampleinputpassword1"                             placeholder="password"  name="password" required=""/>                     </div>                     <div class="form-group">                         <label for="exampleinputpassword2">confirm password</label> <input                             type="password" class="form-control" id="exampleinputpassword2"                             placeholder="re-enter password"                              name="confirm_password" required=""/>                     </div>                      <label class="radio-inline"> <input type="radio" name="gender" value="male">male                     </label> <label class="radio-inline"> <input type="radio"                         name="gender" value="female">female                     </label>                      <div class="checkbox ">                         <label id="lgcheck"> <input type="checkbox" name= "terms"/> check me out                         </label>                     </div>                     <button type="submit" class="btn bsubmit btn-primary" name="submit">submit</button>                  </form>               </div>              <!-- modal footer -->             <!-- <div class="modal-footer">                 <button type="button" class="btn btn-primary" id="save"">save                     changes</button>                 <button type="button" class="btn btn-default" id="close"                     data-dismiss="modal">close</button>             </div> -->         </div>     </div> </div> 

this home.php file

     <?php include_once 'header.php';?>       <?php include_once 'db/conection.php';?>        <div class="container"> <div class="row"> <?php $register = array (); /* form required field validation */ if (isset ( $_post ['submit'] )) {     if (isset ( $_post ['useremail'] )) {         $useremail = $_post ['useremail'];     }      if (isset ( $_post ['name'] )) {         $name = $_post ['name'];     }     if (isset ( $_post ['password'] )) {         $password = $_post ['password'];     }      if (isset ( $_post ['confirm_password'] )) {         $confirm_password = $_post ['confirm_password'];     }      $my_query = "select * users username '$useremail' ";     $res = mysqli_query ( $conn, $my_query );      if (mysqli_num_rows ( $res ) > 0) {         echo "user exists";     } else {         $my_query = "insert users (username,email,password,phonenumber) values ('$useremail','$name','$password','$confirm_password') ";         if ($conn->query ( $my_query ) === true) {             echo "registered successfully";         } else {              echo "failed" . "</br>" . $conn->error;         }     }  }else{     echo "hiii"; } ?></div> 

i want redirect same homepage without resubmittimg form.


Comments