KingChaos Posted August 12, 2007 Share Posted August 12, 2007 Hi. Is ther a way to use one login form to login to multiple pages? Here is my login form: <form action="login.php" method="post" name="login"> <!-- Show a simple login form --> <input type="text" name="username" value="username"> <input type="password" name="password" value="password"> <input type="submit" value="login" name="login"> </form> This logs me in to my main site. But I also needs it to login to /forum/login.php at the same time. Any easy way to do this? King Quote Link to comment https://forums.phpfreaks.com/topic/64505-one-form-multiple-logins/ Share on other sites More sharing options...
MrBillybob Posted August 12, 2007 Share Posted August 12, 2007 yes once they are logged in set a session variable and check it on each page Quote Link to comment https://forums.phpfreaks.com/topic/64505-one-form-multiple-logins/#findComment-321537 Share on other sites More sharing options...
Guest Posted August 12, 2007 Share Posted August 12, 2007 When you do this in PHP <?php session_start(); $_SESSION['userIsLoggedIn'] = true; ?> That userIsLoggedIn value becomes available to you anywhere at anytime for a certain amount of time (so long as you use session_start()). So as long as login.php makes a $_SESSION variable that as the same name, the site will maintain login "state" until you destroy that variable (or destroy the session). Quote Link to comment https://forums.phpfreaks.com/topic/64505-one-form-multiple-logins/#findComment-321547 Share on other sites More sharing options...
KingChaos Posted August 12, 2007 Author Share Posted August 12, 2007 I dont think this will work since it's users from 2 different databases. It's one login for my main site and one for a forum. Quote Link to comment https://forums.phpfreaks.com/topic/64505-one-form-multiple-logins/#findComment-321618 Share on other sites More sharing options...
nloding Posted August 12, 2007 Share Posted August 12, 2007 Why can't they be one database? Besides, even if the forum is a separate database and not just another set of tables, why can't the $_SESSION['logged_in'] variable be used? Quote Link to comment https://forums.phpfreaks.com/topic/64505-one-form-multiple-logins/#findComment-321629 Share on other sites More sharing options...
KingChaos Posted August 12, 2007 Author Share Posted August 12, 2007 Well.. I'm a newbie.. Maybe it can... I really dunno.. Can someone give me a little more info on how to do this? As I said I'm a newbie to this. But here's alittle info from someone else who did this. But they wont give more info unless they get paid: once they use the site login to login to the forum it will set a cookie and login them in straight away in furture just edit the login page on the forum so the remember me box is already ticked Thanx so far guys. I'm sure someone out here is able to help me solv this. King Quote Link to comment https://forums.phpfreaks.com/topic/64505-one-form-multiple-logins/#findComment-321693 Share on other sites More sharing options...
nloding Posted August 12, 2007 Share Posted August 12, 2007 You've got one database, called "MySite" or whatever. You connect to it using the usual methods (mysql_connect() or whatever). Then you have tables inside that. TABLE "users" -- contains user information, like id, last login time, etc. userid username password fullname lastlogin TABLE "forum" -- contains the main page of the forum listing the subforums (like PHP Help, MySQL Help, etc. on the main page of this site) subforumid subforumname TABLE "forum_threads" -- contains the threads for the subforum threadid subforumid treadtopic threadstarted TABLE "forum_posts" -- contains the posts postid threadid postauthor postcontent Anyhow, that's not the best laid out schema for a forum, but they're all part of the same database. If that's still confusing (it was to me when I first saw it), think of it like an Excel file. In Excel, it's a single .xls file, but there are multiple workbooks inside that can influence each other. The database is the file, the tables are the workbooks. Once that is setup, their login is good for everything on the site using sessions. Quote Link to comment https://forums.phpfreaks.com/topic/64505-one-form-multiple-logins/#findComment-321715 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.