General Programming Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingGeneral Programming Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old October 9th, 2003, 02:33 AM
thecharking thecharking is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2003
Posts: 187 thecharking User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
Send a message via AIM to thecharking
make all url variables one variable on page....

I was wondering how I can direct users to a login page, and then back where they were going... I've figured that to do it I would jsut check to see if the user is logged in, and if not, use header(location: url);. But when they log in, they will be sent to index.php (thats the header I have after login is done). I figured maybe I could just somehow get ALL variables sent through the url and make them one variable which I could just do header(location: $var);. Can this be done? getting all variables into one var? I could concactanate. But without know what vars have been sent, can I jsut grab them ALL? Or jsut assume a variable may have been sent.
How do other websites do this, if this isnt how?
thanks!
__________________
hey it's the CHARKING

Reply With Quote
  #2  
Old October 9th, 2003, 04:03 AM
digitallysmooth digitallysmooth is offline
you know how we do
Dev Articles Novice (500 - 999 posts)
 
Join Date: Jun 2002
Posts: 788 digitallysmooth User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 34 m 21 sec
Reputation Power: 7
Off the top of my head the following should be of use:

I assume you are using a function to do the login check, then in that function you redirect the user to the correct location. Modify your function to take a location parameter. It should be optional so give it a default value or leave it blank by default.

Check for the value first, if it exists then use it.
To fill this variable/parameter, you would need to actually grab the page the user was trying to access.

In order to do this, I assume you are using an include to validate a logged in session or cookie, so at that point you should gather the location information.

You can use $_SERVER['REQUEST_URI']
This will give you the name of the script (relative to the server's document root), and the associated query string.

If you want to consider POST variables also you will need to put in more work.

If you wanted Get and Post Variables you would have to use $_SERVER["REQUEST_URI"] and append the query string to that.

To get the querystring values you could create an array like the following:

$qs_array = array_merge($_POST, $_GET);
foreach ($qs_array as $key=>$value) $qs .= "$key=$value";
__________________
__________________________________________________ _
Wil Moore III, MCP | Integrations Specialist | Senior Consultant
Are You Listed...? | DigitallySmooth Inc.

Reply With Quote
  #3  
Old October 10th, 2003, 03:30 PM
mjlivelyjr mjlivelyjr is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2003
Location: Idaho, US
Posts: 9 mjlivelyjr User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
I created a fairly handy authentication script that I use on most sites that require form-based authentication.

it uses the following function (I am

function checkAuth() {
//Perform code that ensures that the user is authenticated

//if the user is not yet authenticated
if (!$auth) {
$pageAfterAuth = 'http://' . $_SERVER['SERVER_NAME'] . $_SERVER['PHP_SELF'] . '?' . $_SERVER['QUERY_STRING'];

header("login.php?redirect=" . urlencode($pageAfterAuth));
}
}

then on login.php you could display your form and be sure to include a hidden form field named 'redirect' that contains the value of $_REQUEST['redirect'] as its value. On the page that processes the logon you could then include the following code:

//perform code to log user in and set cookies or whatever

//check to see if the redirect variable is set
if (array_key_exists('redirect', $_REQUEST)) {
header('Location: ' . $_REQUEST['redirect']);
} else {
//otherwise you could send them to a default location
header('Location: /index.php');
}


That is probably more involved than you were looking for but it is just a simple overview of I how I do it and it has worked well for me.

Reply With Quote
  #4  
Old October 16th, 2003, 07:38 PM
thecharking thecharking is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2003
Posts: 187 thecharking User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
Send a message via AIM to thecharking
just wanted to say hanks, and although I don't think I understood the first example I figured out the other one with the querystring fetching... thats a cool thing to know. thanks both of you!

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingGeneral Programming Help > make all url variables one variable on page....


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway
Stay green...Green IT