You can try to detect this event from the browser back button with javascript in this way. But I’m not sure if it will fully work for the purpose you need:
var url = "http://localhost/seuaplicativo/updateBanco.php";
function updateBanco(e) {
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if(this.readyState == 4 && this.status == 200) {
console.log("Sucesso");
}
};
xhttp.open("GET", url+"?url="+encodeURI(document.location), true);
xhttp.send();
}
window.onpopstate = updateBanco;
and in PHP do something similar to this:
updateBanco.php
$url = $_GET["url"];
$banco = mysql_query("localhost", "root", "");
$db = mysql_select_db("controle_de_navegacao");
$query = mysql_query("INSERT INTO tabela (id, url) VALUES (NULL, "{$url}")");
echo $query ? "OK" : "OPS";
?>
What happens: When javascript detects the back or forward function of the browser, it will trigger a request to PHP on the server that will make the record you expect.
Your doubt is too wide. Are you trying to control the pages the user browses in the database? Code examples?
– Whatyson Neves
Yes, the big question would be, how can I intercept user drive between the pages of my system.
– Roberto Albino