1

I am using Go back for going back in php using following code.

mycode.php

<script>
function goBack() {
    window.history.back();
}
</script>
<button onclick="goBack()" style="float: right;">Back</button>

but it does not seem to be working. As my previous page is having R code which need to be executed.

previous_code.php

  <?php

            exec('Rscript code.R '.$tmpdir.'group_selected.txt '.$type.' '.$tmpdir);

            $file = fopen($tmpdir."file.txt", "r");
            $i=0;
            while(!feof($file)){
                  $line = fgets($file);
                  if($line){
                      $line=str_replace('"', "", $line);
                     echo "<option value='$line'>".$line."</option>";
                  }
                  $i++;
                  if($i%3==0){echo "</tr><tr>";};
            }
            fclose($file);
            ?>    

When i click Go back on mycode.php, it shows blank page

enter image description here

May i know how can i fix this issue?

  • Possible duplicate of [window.history.back() shows "Document Expired" page, any way around that?](http://stackoverflow.com/questions/14965718/window-history-back-shows-document-expired-page-any-way-around-that) – cmorrissey Nov 18 '16 at 21:25
  • @cmorrissey which means i need to use Get method to point to previous page like
    ?
    – manish kumar Nov 18 '16 at 21:40
  • @manishkumar Ideally a form uses the POST method. After succesful processing of your form data you could do a redirect (in PHP) to a GET route / url, which will then be the response URL for your front-end, and the target of your `back()` call. – JJWesterkamp Nov 18 '16 at 23:00

0 Answers0