Jump to content

Redirect to a specific URL on failure to login!


benyates1

Recommended Posts

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

Link to comment
Share on other sites

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");}

 

 

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.