redirecting to previous page after registering session value

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
fadi
Forum Newbie
Posts: 10
Joined: Wed Mar 24, 2004 1:26 am
Location: Asia:Pakistan

redirecting to previous page after registering session value

Post by fadi »

Hi All!
i want to know any method of how can i redirect to previous page from where i logged on after registering sessions variables..so use doesnt have to navigate throughout the sitemap.
infact i've many pages of login option..i just want that user just puts his user id pwd and registers it in session and redirects to the previous page..how can i accomplish that ? are session variables capable enough for this purpose ?
regards..
Harlequin
Forum Commoner
Posts: 51
Joined: Tue Sep 21, 2004 10:51 am
Location: UK

Post by Harlequin »

Fadi

If all you want to do is send someone back to the page they were on whilst ensuring the session variables are logged you could simply give them a back button.

If you want to do this automatically, which I suspect would irritate the hell out of your users you could force a refresh and use client side script to send them back.

I'd recommend a back button though as forcing a refresh and back will be very annoying for your users.
User avatar
phpScott
DevNet Resident
Posts: 1206
Joined: Wed Oct 09, 2002 6:51 pm
Location: Keele, U.K.

submit to itself

Post by phpScott »

Why not just have the page submit to itself and have the page determine which login option to use.
It would save have to use back buttons, header redirection and the like.
Breckenridge
Forum Commoner
Posts: 62
Joined: Thu Sep 09, 2004 11:10 pm
Location: Breckenridge, Colorado

Post by Breckenridge »

if you must; use a header() and pass the session_id
i.e.

Code: Select all

<?
header ("location: http://domain.com/page.php?PHPSSID=$YOU ... D_VAR_HERE");
?>
User avatar
Joe
Forum Regular
Posts: 939
Joined: Sun Feb 29, 2004 1:26 pm
Location: UK - Glasgow

Post by Joe »

Or you could redirect to the previous page by using something like:

untested:

Code: Select all

<?php
print("<meta http-equiv=refresh content='1; url=http://www.yoursite.com/.".$_SERVER['HTTP_REFERER']."'>");
?>
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

note: do not bank on HTTP_REFERER existing... ;)
Post Reply