0

I have two <input type ="submit"> with formaction inside a <form method="post" action=""> and these suckers prompt the Confirm Form Resubmission on refresh:

<form method = "post" action="">
  <input class = "button" type="submit" name="dhcp" value="DHCP IP" title="Redirect to DHCP IP Config page" formaction="/dhcp_ip.php">
  <input class = "button" type="submit" name="static" value="Static IP" title="Redirect to Static IP Config page" formaction="/static_ip.php">
</form>

I was led to believe that <form method="post"> or any POST method prompts Confirm Form Resubmission so I have eliminated the form and replaced it with two button elements:

<button class="button" onclick="goDHCP()">DHCP IP</button>
<button class="button" onclick="goStatic()">Static IP</button>
<script>
    function goDHCP() {
        window.location.replace("/dhcp_ip.php");
    }
    function goStatic() {
        window.location.replace("/static_ip.php");
    }
</script>

But this also prompts Confirm Form Resubmission on refresh.

What element prompts it ? And how can I not prompt it ? Because I also have some <input type="text">, on other pages, which do not prompt Confirm Form Resubmission on refresh, unless the user starts typing something in them.

bleah1
  • 471
  • 3
  • 18

1 Answers1

1

Confirm Form Resubmission means that you are trying to refresh a page where data was sent to. If you don't want to have this popup, click the URL bar and hit enter to revisit the same page without sending data.

As to your form...

<?php 
if (!empty($_POST['submit'])) {
   echo '
      <script type="text/javascript">
         window.location.replace("/'.$_POST['direction'].'.php");
      </script>
   ';
}
?>
<form method="post" action="">
   <select name="direction">
      <option value="dhcp_ip">Redirect to DHCP IP Config page</option>
      <option value="static_ip">Redirect to the Static IP Config page</option>
   </select>
   <button type="submit" name="submit" value="submit">
     Visit page
   </button>
</form>

If you need any explanations, please let me know.

Thrallix
  • 699
  • 5
  • 20