如何创建一个按钮,重定向到用户在HTML或PHP中查看的最后一页[关闭]

Anyone knows the logic or knowledge to do this thing ? I have 5 html/php pages and a menu page, in the menu page there is a buttons that lead to 5 pages and a button that will direct to the last page viewed by the user.

You can easily do this with javascript: <a href="javascript:history.back();">Back</a>

Source (german)

Create a JavaScript function that sends the browser back

function goBack() {
window.history.back()
}

Then create a button that the user clicks

<button onclick="goBack()">Go Back</button>

Php:

<a href="<?php echo $_SERVER['HTTP_REFERER']; ?>">Back</a>