Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 02-25-2008, 11:42 PM   PM User | #1
tomyknoker
Regular Coder

 
Join Date: Mar 2006
Posts: 459
Thanks: 3
Thanked 0 Times in 0 Posts
tomyknoker is an unknown quantity at this point
Re-Direct To A Page After Login

Hi all... I am sending out a e-newsletter, with a link to a page... However the to access the site people need to login, how could I re-direct the user once they logged in to this page? I only want it to happen with people who get the newsletter, regular users who login don't need to be re-directed... I thought this was a JavaScript issue so posted there first but think it may be php and variables...
tomyknoker is offline   Reply With Quote
Old 02-25-2008, 11:47 PM   PM User | #2
Fumigator
UE Antagonizer


 
Fumigator's Avatar
 
Join Date: Dec 2005
Location: Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
Posts: 7,686
Thanks: 42
Thanked 637 Times in 625 Posts
Fumigator is a glorious beacon of lightFumigator is a glorious beacon of lightFumigator is a glorious beacon of lightFumigator is a glorious beacon of lightFumigator is a glorious beacon of light
First of all let me just say there's probably a better way to do this.

But I would do it via a $_GET value (query string) on the login script, which you would then catch after a successful login and redirect.
__________________
Fumigator is offline   Reply With Quote
Old 02-26-2008, 12:18 AM   PM User | #3
Inigoesdr
Super Moderator


 
Inigoesdr's Avatar
 
Join Date: Mar 2007
Location: Florida, USA
Posts: 3,601
Thanks: 2
Thanked 397 Times in 390 Posts
Inigoesdr is a jewel in the roughInigoesdr is a jewel in the roughInigoesdr is a jewel in the rough
Quote:
Originally Posted by Fumigator View Post
First of all let me just say there's probably a better way to do this.
No, that should be the best way unless the OP wants to make a separate login script for the newsletter links(not what I would recommend).
Inigoesdr is offline   Reply With Quote
Old 02-26-2008, 12:22 AM   PM User | #4
tomyknoker
Regular Coder

 
Join Date: Mar 2006
Posts: 459
Thanks: 3
Thanked 0 Times in 0 Posts
tomyknoker is an unknown quantity at this point
I don't really understand how I would do this though... So I give them a link but add variables in the url?
tomyknoker is offline   Reply With Quote
Old 02-26-2008, 12:46 AM   PM User | #5
Inigoesdr
Super Moderator


 
Inigoesdr's Avatar
 
Join Date: Mar 2007
Location: Florida, USA
Posts: 3,601
Thanks: 2
Thanked 397 Times in 390 Posts
Inigoesdr is a jewel in the roughInigoesdr is a jewel in the roughInigoesdr is a jewel in the rough
Yeah, you would send them a link like http://www.domain.com/login.php?newsletter=true then pass it through the session when the login form loads:
PHP Code:
$_SESSION['newsletter'] = true
And finally in the login code, forward them:
PHP Code:
if(!empty($_SESSION['newsletter']))
     
header('Location: newsletterinfo.php');
// might want to unset the newsletter variable here 
Inigoesdr is offline   Reply With Quote
Old 02-26-2008, 02:52 AM   PM User | #6
Fumigator
UE Antagonizer


 
Fumigator's Avatar
 
Join Date: Dec 2005
Location: Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
Posts: 7,686
Thanks: 42
Thanked 637 Times in 625 Posts
Fumigator is a glorious beacon of lightFumigator is a glorious beacon of lightFumigator is a glorious beacon of lightFumigator is a glorious beacon of lightFumigator is a glorious beacon of light
Yep that's exactly what I had in my head, thanks Inigoesdr for pulling the code out of my head (I was too lazy to give the example and hoped my explanation would be enough)
__________________
Fumigator is offline   Reply With Quote
Old 02-26-2008, 09:14 PM   PM User | #7
aedrin
Senior Coder

 
Join Date: Jan 2007
Posts: 1,648
Thanks: 1
Thanked 58 Times in 54 Posts
aedrin will become famous soon enough
It would be a lot more effective/abstract to pass a relative URL to the login script.

Upon loading, the script checks if they are logged in or not. If they aren't, forward to login page (appending the current relative URL to the forward).

Then the login page uses that to forward back to the original page.

For example:

Code:
Original: www.domain.com/newsletter/
Login Forward: www.domain.com/login.php?returnURL=newsletter/ (this needs to be urlencode()d).
This way you can reuse the code for the login page.
aedrin is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 09:57 AM.


Advertisement
Log in to turn off these ads.