php - $_SERVER['HTTP_REFERER'] not working with Header -


I have a site that allows public access to some pages, but others need to log in with me There is a link to login from all pages, and the user I want to make after successful login sends the user back to that page when they clicked on the login link. I know that the HTTP_REFERER can be tricked, and sometimes taken by some host and proxy, but since it is strictly within my own site, and there is only one feature for users, I I am not very worried about.

I'm curious about why he is not working in conjunction with a redirect, though. I have set up a visual field to include the value of an HTM referrer, and it displays correctly. So the page is getting the value of the referrer variable but when I try:

  $ home_url = $ _SERVER ['HTTP_REFERER']; Header ('location:' $ Home_url);  

This does not work, on the other hand, it does:

  $ home_url = 'http: //'. $ _SERVER ['HTTP_HOST'] dirname ($ _ server ['PHP_SELF']) '/ discussions.php'. Header ('location:' $ Home_url);  

So I know that the header space works in the works. Any idea why it does not want to work with combinations with the http_referer variable? << / P>

(Besides this, does it drive anything else that the spell has spell misspelled? I keep it wrong by using the OD spelling, I'm stupid ...) / P>

.

login page What can you do, where the user enters the details, the login page is a hidden field with the request of the request, and then enter it on the script which verifies the login and forwarding if the login is successful Better.

Better yet: Since the user can not send the referrer (it is configurable in most browsers), the link in the login page is included in the query string Go to the original page as the above, but use this value instead of the referrer.

To be clear:

  
= "Post" action = "login" & gt; ... & lt; Input name = "user" type = "text" /> & Lt; Input name = "password" type = "password" /> & Lt; Input name = "referer" type = "hidden" value = "& lt ;? php echo urlencode ($ _ SERVER ['HTTP_REFERER'])? & Gt; / & Gt; & Lt; / Form & gt;

then

  & lt ;? Php if (login_s_fulf (amp; amp; amp; amp; amp; blank) ($ _ POST ['referer']) & amp;! Is_array ($ _ POST ['referer'] )) {Header ("location:" .rudcode ($ _ POST ['referrer'])); Die (); }  

Comments