Page 1 of 1

Forwarding people after login

Posted: Fri Jun 22, 2007 11:40 am
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.

Posted: Fri Jun 22, 2007 11:44 am
by gnetcon
Try:

Code: Select all

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

HTH!

Posted: Fri Jun 22, 2007 11:49 am
by .Stealth
Oh thankyou very much.
works perfect :D