alvinchua Posted May 5, 2007 Share Posted May 5, 2007 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... Quote Link to comment https://forums.phpfreaks.com/topic/50152-redirect-the-user-to-his-own-page-once-it-login/ Share on other sites More sharing options...
MadTechie Posted May 5, 2007 Share Posted May 5, 2007 erm.. you lost me, redirect use to his own database.. Quote Link to comment https://forums.phpfreaks.com/topic/50152-redirect-the-user-to-his-own-page-once-it-login/#findComment-246257 Share on other sites More sharing options...
triphis Posted May 5, 2007 Share Posted May 5, 2007 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 Quote Link to comment https://forums.phpfreaks.com/topic/50152-redirect-the-user-to-his-own-page-once-it-login/#findComment-246260 Share on other sites More sharing options...
pocobueno1388 Posted May 5, 2007 Share Posted May 5, 2007 Yes, you can do it that way. Quote Link to comment https://forums.phpfreaks.com/topic/50152-redirect-the-user-to-his-own-page-once-it-login/#findComment-246262 Share on other sites More sharing options...
alvinchua Posted May 6, 2007 Author Share Posted May 6, 2007 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 ??? Quote Link to comment https://forums.phpfreaks.com/topic/50152-redirect-the-user-to-his-own-page-once-it-login/#findComment-246636 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.