Okay so first off, sorry if this is a duplicate. I've searched for around 20 minutes all over stack overflow AND the internet, and I can't seem to find a solution to my problem.
What I'm trying to do:
I have a login form on every page, with a hidden input containing the current page the user is on - so when they login, it successfully redirects back to the page they were on.
E.g. User is on news.php and not logged in. They login, which takes them to login.php to verify data, then redirects back to news.php
This works great!
The problem: If there is any get data or anchor tags at the end of the URL, I can't seem to redirect back to that.
E.g. User is on news.php?id=4#comments and not logged in. They login, etc etc, but it redirects back to news.php and ignores the trailing data.
Anyone have any help here?
My code:
<input type="hidden" value="<?php echo $_SERVER['HTTP_REFERER']; ?>" name="location" />
$previousPage = $_POST['location'];
header("refresh: 1; url=".$previousPage);
Obviously I think the issue is the $_SERVER['HTTP_REFERER'] part, but I'm not sure what to replace it with to make it include trailing data.
All help is appreciated!