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
https://forums.phpfreaks.com/topic/20879-user-have-to-login/#findComment-92492
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
https://forums.phpfreaks.com/topic/20879-user-have-to-login/#findComment-92498
Share on other sites

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.