A web site I'm trying develop has several pages that won't open unless the user is logged in. If not logged in, the user is redirected to a login page that tells the user why they were reditrected.
Prior to the redirection, a SESSION variable stores the path back to the page the user was redirected from.
The user gets to login (user name & password), clicks 'Submit', gets a message that the login was valid.

Then if the user clicks the 'Return' button, I want him returned to the calling page, whichever one it was.

I have tried multitudes of keystrokes to try to make this work, too many to post them all but most are a variation of this:

<input type="submit" class="submit_button" value=" Back " onclick="location.href = <?php echo $linkback; ?> style="font-weight: 700" />

$linkback is the SESSION variable that was set previously pointing back to the calling page. The SESSION data is correct, there is no error, it just refreshes the login page.
Also, the 'Back' fucntion using 'history(-1)' doesn't work because the previous page is not n the history after the redirect to the login page.

Any help would be appreciated.

your getting a js error because your link syntax is wrong

onclick="location.href = <?php echo $linkback; ?>
you need single quotes around the link and your missing the closing double quotes after onclick
onclick="location.href = '<?php echo $linkback; ?>'"
and the submit part of the button is firing causing you to submit your page back to its self

Exactly the help I needed!
The solution worked perfectly (after I corrected a typo) and resolved a problem I had been working on for many hours.

Thanks again.
Dougsix

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.