Jump to content

referer check not working


funbinod

Recommended Posts

i'm trying to check before going to login page it should be checked if it is activated or not. if someone tries to access 'login.php' directly, it should be forwarded to 'chkactivation.php'. for this i tried--

// login.php$ref = $_SERVER['HTTP_REFERER'];if ($ref != 'http://localhost/ac/chapat/chkactivation.php') {	die(header("location: chkactivation.php"));}

but it says "This page can't be displayed" as if it didn't find the page (login.php) in spite of redirecting to 'chkactivation,php'.

where m i wrong? please guide.. or suggest some better idea...

Link to comment
Share on other sites

header() should not be inside die(). you can use header() to redirect and the may call die()

Link to comment
Share on other sites

Well, I forgot header() does return void. I recalled it would return boolean (on success/failure) and thought different thing. NVM.

 

Back to your problem. "This page can't be displayed" does it show error 404?

Link to comment
Share on other sites

I am not sure from where you get the error message. if page does not exist it would show error 404. currently it will try to redirect to file named chkactivasion.php on same directory as login.php. make sure file URI is correct.

Link to comment
Share on other sites

i wonder for same. file name is perfect. no error.

 

let me explain u the error that is happening...

 

i added the above line to 'login.php'. after adding the lines, 'login.php' fails to load and gives the error msg. removing the lines, 'login.php' opens correctly. if it was only the case of wrong file name 'chkactivation.php', it should al least redirect to the file and not open. but its not redirecting to the <header("location: chkactivation.php")>.

Edited by funbinod
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...