html - "Double Load" Issue with PHP isset() and $_POST data -


i know doing wrong using combination of isset(), $_post , $_get wondering easiest , painless way tackle issue.

the issue arises when submit html form... reloads page post data. capture submit php isset() function, process $_post data , run window.location refresh page $_get data.

for example...

//example.php ...  <form action="" method="post">    <input name="stage1name" type="text" class="textfield" size="22" value="<?php echo $claimrow['claimantname']; ?>">   <input name="vehicleengine" type="text" class="textfield" size="20" value="<?php echo $vehiclerow['vehicleengine']; ?>">   <input name="vehiclefuel" type="text" class="textfield" size="20" value="<?php echo $vehiclerow['vehiclefuel']; ?>">    <input name="submitinfo" type="submit" value="<?php echo $lang_claims_change_info; ?>" />  </form>  ... <?php        if (isset($_post['submitinfo']))     {          $stage1name= mysqli_real_escape_string($db, $_post['stage1name']);         $vehicleengine= mysqli_real_escape_string($db, $_post['vehicleengine']);         $vehiclefuel= mysqli_real_escape_string($db, $_post['vehiclefuel']);         mysqli_query($db, "do cool sql here");          //i've done need lets reload page updated data          echo "<script>window.location='example.php?vehicle=" . $vehicleid . "&claimtab=personal'</script>";      } ?> 

like said before, method works fine user gets effect of "double load" , epiletic fit inducing.

any ideas how best combat this?

thanks

edit - additional example

i realised 1 example might not make complete sense put example will.

...  <form action="" method="post">       <select name="addresstype[]" id="multiselectfrom" onchange='this.form.submit();' size="9" style="width:110px; text-align:center;">         <option style="<?php if ($addtype == 'claimant') { echo'background-color:#9ad3f1 !important;'; } ?>" value="claimant"><?php echo $lang_claims_claimant; ?></option>         <option style="<?php if ($addtype == 'vehicle') { echo'background-color:#9ad3f1 !important;'; } ?>" value="vehicle"><?php echo $lang_claims_vehicle; ?></option>         <option style="<?php if ($addtype == 'repairer') { echo'background-color:#9ad3f1 !important;'; } ?>" value="repairer"><?php echo $lang_claims_repairer; ?></option>         <option style="<?php if ($addtype == 'insurer') { echo'background-color:#9ad3f1 !important;'; } ?>" value="insurer"><?php echo $lang_claims_insurer; ?></option>         <option style="<?php if ($addtype == 'fleet') { echo'background-color:#9ad3f1 !important;'; } ?>" value="fleet"><?php echo $lang_claims_fleet; ?></option>     </select> </form>  ...  <?php     if (isset($_post['addresstype']))     {          foreach ($_post['addresstype'] $addresstype) {             $addresstype2 = $addresstype;         }         echo "<script>window.location='claims.php?claimid=" . $claim . "&claimtab=addresses&addresstype=" . $addresstype2 . "'</script>";     } ?> 

the above example supposed take result of form , change window.location depending on form result. work loads page twice in doing so.

repalace:

echo "<script>window.location='example.php?vehicle=" . $vehicleid . "&claimtab=personal'</script>"; 

with:

echo "<meta http-equiv = 'refresh' content = '0; url =example.php?vehicle=" . $vehicleid . "&claimtab=personal'>"; 

Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -