funbinod Posted May 15, 2014 Share Posted May 15, 2014 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 More sharing options...
birbal Posted May 15, 2014 Share Posted May 15, 2014 header() should not be inside die(). you can use header() to redirect and the may call die() Link to comment Share on other sites More sharing options...
funbinod Posted May 15, 2014 Author Share Posted May 15, 2014 (edited) but this is working if (!$connect) { die(header("location: install.php?"));}else { die(header("location: login.php?"));} Edited May 15, 2014 by funbinod Link to comment Share on other sites More sharing options...
birbal Posted May 15, 2014 Share Posted May 15, 2014 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 More sharing options...
funbinod Posted May 15, 2014 Author Share Posted May 15, 2014 never mind. no 404. gives only the message. Link to comment Share on other sites More sharing options...
birbal Posted May 15, 2014 Share Posted May 15, 2014 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 More sharing options...
funbinod Posted May 15, 2014 Author Share Posted May 15, 2014 (edited) 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 May 15, 2014 by funbinod Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now