Forwarding people after login

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
.Stealth
Forum Commoner
Posts: 57
Joined: Wed Jan 10, 2007 12:15 pm
Location: Manchester, England

Forwarding people after login

Post by .Stealth »

hello, im halfway through a new script when i realized a problem with my login function.

currently when the user's log in, they are forwarded to the document they try to access.

but thats all it does, just the document, for example.

when they click on a link such as:
http://www.example.com/tickets.php?action=view&ticket=7

it forwards people to:
http://www.example.com/tickets.php


but i want it to forward them to whatever variables are on the end.

how do i get all variables from the url to put in the redirection?

heres the current login function:

Code: Select all

function log_in($user, $pass){
	$username = $user;
	$password = $pass;
	$password = md5($password);
	$sql = @mysql_query("SELECT * FROM users WHERE username = '$username' AND pwd = '$password' LIMIT 1;");
	
	if(!$sql){
		exit('Error: 02<br />Unable to verify youdr details, please try again later');
	}

	if(mysql_num_rows($sql) == 1){
		$data =	mysql_fetch_array($sql);
		if(!$data){
		exit('Error: 04<br />Unable to verify your details, please try again later');
	}

	$user_id 		= $data['id'];
	$session_id 	= mktime();
	$session_id 	= md5($session_id);

//INSERT SESSION ID INTO DATABASE


	$sql_ses = mysql_query("UPDATE users SET
							ses_id ='$session_id'
							WHERE id ='$user_id';");

	if(!$sql_ses){
		exit('Error: 03<br />Unable to verify your details, please try again later<br />');
	}

	setcookie('user', $user_id, time() + 7600);
	setcookie('sesh_id', $session_id, time() + 7600);
	header( 'Location: ' . $_SERVER['PHP_SELF']) ;

	return TRUE;
	}else{
		return FALSE;
	}
}

i need to put all of the url variables into the header part but i cant think of a way to get all variables.

i could look at every single page i ask them to log into and get all of the variables if they exist but surley theres is a more simple way?

thanks for any help.
gnetcon
Forum Newbie
Posts: 4
Joined: Fri Jun 22, 2007 11:24 am

Post by gnetcon »

Try:

Code: Select all

$_SERVER["QUERY_STRING"]
This will display all values currently passed.

HTH!
.Stealth
Forum Commoner
Posts: 57
Joined: Wed Jan 10, 2007 12:15 pm
Location: Manchester, England

Post by .Stealth »

Oh thankyou very much.
works perfect :D
Post Reply