benyates1 Posted July 4, 2010 Share Posted July 4, 2010 Hi Folks, Glad to be joining the community. I'm having some trouble trying to get the correct code in place to automatically forward/redirect a user who has cancelled the browser login dialogue box and therefore not managed to successfully access restricted content to a specific page rather than the ugly error page that is default in browsers. Much like i've managed to achieve with my custom 404 error page. I'm pretty sure it can be done but i'm not having too much succes. Any help would be greatly appreciated Many thanks, Ben Quote Link to comment https://forums.phpfreaks.com/topic/206688-redirect-to-a-specific-url-on-failure-to-login/ Share on other sites More sharing options...
robert_gsfame Posted July 4, 2010 Share Posted July 4, 2010 not sure what u re looking for... u mean this $selectquery=mysql_query(sprintf("SELECT * FROM usertable WHERE username='%s' AND password='%s'", mysql_real_escape_string($_SESSION['username']), mysql_real_escape_string($_SESSION['password']))); $selectquerynum=mysql_num_rows($selectquery); if(empty($selectquerynum)){ header("Location:login_fail.php");} Quote Link to comment https://forums.phpfreaks.com/topic/206688-redirect-to-a-specific-url-on-failure-to-login/#findComment-1080960 Share on other sites More sharing options...
benyates1 Posted July 4, 2010 Author Share Posted July 4, 2010 not sure what u re looking for... u mean this $selectquery=mysql_query(sprintf("SELECT * FROM usertable WHERE username='%s' AND password='%s'", mysql_real_escape_string($_SESSION['username']), mysql_real_escape_string($_SESSION['password']))); $selectquerynum=mysql_num_rows($selectquery); if(empty($selectquerynum)){ header("Location:login_fail.php");} Thanks, I'm relying on the default browser login prompt/dialogue, so when there is a link to a file in a protected directory it would redirect the user to a join/alternate page. The same would happen if the user entered the wrong credentials or cancelled the dialogue. I don't have a database of users, that is handled by a payment processor so the easiest way I figure is to intercept unauthorised/forbidden error pages and have it redirect to an alternative page. Thanks Quote Link to comment https://forums.phpfreaks.com/topic/206688-redirect-to-a-specific-url-on-failure-to-login/#findComment-1080967 Share on other sites More sharing options...
trq Posted July 4, 2010 Share Posted July 4, 2010 Sounds like your simply needing to customize the default 403 Forbidden page. Quote Link to comment https://forums.phpfreaks.com/topic/206688-redirect-to-a-specific-url-on-failure-to-login/#findComment-1080971 Share on other sites More sharing options...
benyates1 Posted July 4, 2010 Author Share Posted July 4, 2010 Sounds like your simply needing to customize the default 403 Forbidden page. Yes, I think that is what I need to do. Is it the same process as customising the 404? Quote Link to comment https://forums.phpfreaks.com/topic/206688-redirect-to-a-specific-url-on-failure-to-login/#findComment-1080978 Share on other sites More sharing options...
trq Posted July 4, 2010 Share Posted July 4, 2010 Indeed it is, and nothing at all to do with php. Quote Link to comment https://forums.phpfreaks.com/topic/206688-redirect-to-a-specific-url-on-failure-to-login/#findComment-1080986 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.