Jump to content

allow user to login, and still redirect to specific page from an email link.


njdubois

Recommended Posts

Please keep in mind that I started using php months ago.  I can make it do what I want it to do and have managed to set up a full fledged membership system linked to other sql data sources for a client.  But for the sake of the problem I will simplify my question, cause even I don't know what I am asking.

 

I have a membership site, users can login and what not.... I want to email this user a url to a part of the page when an admin wants to alert the user of something.

 

"www.mysite.com/member_home.php?pet=dog&size=lrg&age=old"

please keep in mind this is a dummy down version.

 

The problem is, if this user isn't currently logged in member_home will redir them to the login page.  The login page redir the browser to the login checking script, which then needs to redir the user to the original url.  How do I pass this url from the original email link, through the whole process?

 

If i'm correct :

"/member_login.php?redir=member_home.php?pet=dog&size=lrg&age=old"

wont work.

 

redir=member_home.php?pet=dog

then it will see size and age as other variables.

 

What do I need to learn to achieve what I am aiming for?

 

Thanks in advance!

Nick

Link to comment
Share on other sites

  • 2 weeks later...

You need to use the $_SERVER global.

 

<?php 
$url = "http://".$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'];
?>

 

Where $_SERVER['SERVER_NAME'] would return www.mysite.com and $_SERVER['REQUEST_URI'] returns "/member_login.php?redir=member_home.php?pet=dog&size=lrg&age=old".

 

You can use a session variable (example $_SESSION['redirect_url']) to store the url, and when the user logs in, check to see if a $_SESSION['redirect_url'] is available, and if it is, then redirect, else, do normal process.

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.