Hello, good morning, I want to know if there is a way to make a page automatically reload because I have problems when giving the button back in the browser does not generate new codes, and I must update the page to make it happen
Hello, good morning, I want to know if there is a way to make a page automatically reload because I have problems when giving the button back in the browser does not generate new codes, and I must update the page to make it happen
Add this header to your PHP to make sure it does not return a cached page:
<?php
header("Cache-Control: no-store, no-cache, must-revalidate, max-age=0");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
?>
The ideal if you use PHP is that when you process the form in php (collect variables and put them in a database for example) make an address with a header.
Example:
<?php //ejemplo
$datos = $_REQUEST['datos'];
$sql = "INSERT tabla SET datos = '" . $datos . "'";
$res = mysql_query($sql);
header("Location:" . $_SERVER['HTTP_REFERER']); //la pagina anterior o poner la pagina que tu quieras
die();
?>
Before I think I've misunderstood the question. If you want to go back to the previous page as the back button of the browser acts, then you should use the history object. You can use the following function:
window.history.back()
You can find the documentation (in Spanish) about this element here .
Thank you so much for your help I really wanted to do it and it worked for me if there is another way to interpret it, it would be worth to help me but I wanted to do it
<input type="hidden" id="refreshed" value="no">
<script type="text/javascript">
onload = function () {
var e = document.getElementById("refreshed");
if (e.value == "no")
e.value = "yes";
else {
e.value = "no";
location.reload();
}
}</script>