Jump to content

redirect the user to his own page once it login


alvinchua

Recommended Posts

hi ppl... i have created a login page .. and i need to redirect the user to his own page once it login.. in the other words.. i need to redirect the user to his own database.. but the login details is stored in another database... just like once you login into your own account and it is displaying only your details.. hmmm how can i do that with php ... what method is easier and suitable ?? if can juz kindly show me how the code look like too... thanks in advance...

hrm o.O;

 

Couldn't you have your login page, submit to a login_check page... and if login successful, then:

 

 header("Location: whateverpage.php?user=" . $username); 

 

Headers have to be set before anything is printed on screen...

 

And whatever.php page could be that person's own "page/database" whatever... you now have their username to make whatever DB queries you need to make

yea i have this code to check

 

$Username   = $_POST['username'];
$password = $_POST['password'];

// check if the user id and password combination exist in database
$sql = "SELECT username 
        FROM register
		WHERE username = '$Username' AND password = '$password'";

$result = mysql_query($sql) or die('Query failed. ' . mysql_error()); 

if (mysql_num_rows($result) == 1)
 {
	// the user id and password match, 
	$_SESSION['record'] = Username; // store username data
	// set the session
	$_SESSION['db_log_in'] = true;

	// after login we move to the main page
	header('Location: main.php');
	exit;
} else 
{
	$errorMessage = 'Sorry, wrong user id / password';
}

 

but i not very sure how to apply your method ... the header:location.php?.user $username... the user is represented as what? $username is what the user type ?? how to match the user to his corresponding database  ???

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.