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