Jump to content

Login and Membership Structure


BenMo

Recommended Posts

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!

Link to comment
https://forums.phpfreaks.com/topic/41706-login-and-membership-structure/
Share on other sites

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.

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.