In most cases, when a user visits a web page, the past page’s URL is stored in document.referrer object.
In most cases, if the user reached the current page by clicking a link, this contains the URL of previous page. It does not work if the user has directly typed the current page’s URL in address bar of web browser or reached the page via form submission.
You can also use history.back() to go back to previous page.
history.back(); //Go to the previous page history.forward(); //Go to the next page in the stack history.go(index); //Where index could be 1, -1, 6, etc. OR window.history.back(); //Go to the previous page window.history.forward(); //Go to the next page in the stack window.history.go(index); //Where index could be 1, -1, 6, etc.
Alternatively, you can also use other techniques such as storing previous page’s value in cookie, URL parameter or server side.
How to Check if JS Object Has Property
How to Auto Increment With Prefix as Primary Key in MySQL
How to Set Initial Value & Auto Increment in MySQL
How to Create DMARC Record for your Domain