Imagine how this works, your in http://your-site.com/page-A and then you go to http://your-site.com/page-b, question is how would you get the url of http://your-site.com/page-A.
It’s easy, just use
In this way, you can get the url of the previous page.
The $_SERVER is a pre defined variable that has lots of useful information, you can just check it out when you do
Hope this helps someone!
Have a happy coding!