Jump to content

Archived

This topic is now archived and is closed to further replies.

simple5imon

User have to login

Recommended Posts

Ive been searching here but cannot find the coding for this  >:(

I'd like it so, users have to login to gain access to the website pages.
[b]ALSO[/b] id like the coding so it shows their name somewhere so they know their logged in!

Hope this is enough info!
Much appreciation  ;)

Share this post


Link to post
Share on other sites
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. 

Share this post


Link to post
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. 

Share this post


Link to post
Share on other sites

×

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.