PHP Redirects?

Hi Everyone,

I have a question regarding php redirects. If you visit the below URL and if your not logged in - your presented with a statement saying you have to be logged in (which is what I want) but after the person clicks on “Click Here” they are taken to the login page where they can login. My question is, how would I redirect visitors back to the car-search page they originally wanted to visit?

This is my php session syntax on the car-search.php page.


if (!isset($_SESSION['myusername'])) {
echo "Hello, you must have an account to view this page. <a href=\\"\\">Click Here</a>!<br>";

Just save the current url in a session variable on each page.
After the login, redirect to that url.