There are several ways to do this:
1) Use browser history - this option depends on whether JavaScript is enabled in the browser:
<a href='javascript:history.back(1);'>Back</a>
2) Use the Referer HTTP address , which usually contains a URL that references the current request:
$link = $_SERVER['HTTP_REFERER'];
3) Use some server-side mechanism that keeps track of the submitted pages and accordingly populates the "href" attribute in the "back" link. This can usually be useful in wizards; in other cases, the overhead may be too high. In addition, you must carefully handle the situation when a user opens a website on several browser tabs.
UPDATE
4) Create specific Back links based on the page relationship hierarchy. See Reply from Matti Virkkunen for details. In fact, this is the most valid way to navigate pages with "hierarchical" relationships ("view a list of items", "section> subsection", "view an object" and "nested objects", etc.).
source share