When people going to comment to my webpage, it will validate first if you are already login yet or not.
If not, then you have to log in first, what I try to doing here is that, after you log in. you will redirect to last page when you try to give a comment
So, I try to redirect page with GET method using PHP header("Location:");
This is my code:
HTML :
<form method="POST" action="addcomment.php">
<textarea class="commentarea" name="comment" placeholder="your comment"></textarea>
<input type="submit" name="submitcomment" value="Comment" />
</form>
addcomment.php :
header("Location:../loginfirst.php?location=".$_SERVER['HTTP_REFERER']);
it will send to loginfirst.php page, and the url will look like this :
http://localhost/ayojo/loginfirst.php?location=http://localhost/ayojo/product.php?p=test
After that, I try this code on loginfirst.php :
$_GET['location'] = $test;
header('Location:'.$test);
Finally, I try log in then success. but, php header redirect me to the loginfirst.php not on the $_GET['location'].
What's wrong with my code?