I have a database where users are allowed to update records via an edit page. After submitting the edits, I'd like the browser to automatically go back to the page they updated to see the results. I thought about using JS to accomplish this:
if(mysqli_query($con, $sql)){
echo "<script> alert('You have successfully updated.');
window.location.href='javascript:history.go(-2)';
</script>";
}else{
echo "An error has occurred. Please go back and check the code: ".mysqli_error($con);
}
but this only forces the browser to go back to the page and not a refreshed page with the changes visible. I need to manually refresh the page to see the results this way.
I also tried:
if(mysqli_query($con, $sql)){
echo "<script> alert('You have successfully updated.');
window.location.href='01T.php?id=$id';
</script>";
}else{
echo "An error has occurred. Please go back and check the code: ".mysqli_error($con);
}
since 01T.php is the page with the displayed info on it, but that didn't work.
How do I redirect the browser to the same id that was edited to see the results, using a more proper PHP solution?