BenMo Posted March 8, 2007 Share Posted March 8, 2007 Hello, I'm a PHP beginner, and I'm trying to build a simple site that has basic login functions, such as allowing them to sign up by entering their email and password, and then logging in and have the site display their account's data on various pages. I've created pages that allow them to create an account and login and log out of the account, but I'm not sure how to go about the structure of creating a collection of pages where information about the account is accessible at all times. For example, on a given page I'd like to be able to pull out whether or not they are logged in, and if they are, display their name on the page. The only strategies I've used so far are $_POST and some forms; is this all I need? Where can I find some good tutorials on how to pass data around in between pages in this manner? Or any general framework help would be great. Thanks so much! Quote Link to comment https://forums.phpfreaks.com/topic/41706-login-and-membership-structure/ Share on other sites More sharing options...
redbullmarky Posted March 8, 2007 Share Posted March 8, 2007 you'd be looking at storing the username and / or user id in the $_SESSION array just after the login has been confirmed to be valid. a call to session_start() at the top of each of your pages will make this info available. <?php session_start(); if (isset($_SESSION['user_id']) && $_SESSION['user_id'] > 0) { echo 'Hello ' . $_SESSION['user_name'] . '!'; } ?> obviously a lame example, but it should give you an idea to get started. Quote Link to comment https://forums.phpfreaks.com/topic/41706-login-and-membership-structure/#findComment-202720 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.