Jump to content

User have to login


simple5imon

Recommended Posts

There's a login tutorial on this site that works fine. 

As for making sure they're logged in to view any pages, all you do is make a file called logincheck.php or something, and put this inside
[code]
<?
session_start();
if(empty($_SESSION['username'])) {
  header("location: index.php");
}
?>
[/code]

Then at the top of each page (Except index.php), put this
[code]
<?
session_start();
include 'logincheck.php';
?>
[/code]

This works in conjunction with the login tutorial on the site. 
Link to comment
Share on other sites

Here's the tutorial:
http://www.phpfreaks.com/tutorials/65/0.php

You'll have to change some of the table to fit what you need, which will in turn make it so you need to change some other stuff as well, but it won't be hard.  Since you're doing a site, I doubt you'll have people use their real names, so you don't need a first name or last name, just a username.  Things like that, they're not too hard to watch out for.  Also, you don't need to bother with the marketing stuff, just the membership system. 
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.