|
-
Apr 11th, 2004, 02:34 AM
#1
Thread Starter
Frenzied Member
Login Page
Hi I've asked this before but I still have no idea what to do with this.
I have a SQL database with my members, I have a page which asks them to enter their username and password now on this form I want to to authenticate my member and set the cookies so they can enter my restricted pages.
Also I want to add a code to my pages which will redirect them to the login page if they have not done so so far.
Can anyone help?
I have looked on hotscripts.com al seem to be long as codes with endless useless admin pages ect which mean nothing to me.
-
Apr 11th, 2004, 09:21 AM
#2
<?="Moderator"?>
you could use session to store if they are logged in or not
PHP Code:
if(empty($_SESSION['loggedin'] )){
header('Location: login.php');
}
-
Apr 11th, 2004, 05:32 PM
#3
Stuck in the 80s
Are you having a specific problem? This was spelt out fairly well for you in the other thread. Did that not work for some reason? Do you have any code now that we could help you with?
-
Apr 11th, 2004, 09:53 PM
#4
Thread Starter
Frenzied Member
Originally posted by The Hobo
Are you having a specific problem? This was spelt out fairly well for you in the other thread. Did that not work for some reason? Do you have any code now that we could help you with?
well to be honest i don't know were to start. I guess I first need to set up a auth.php whic h will check is the username and password match the ones that are in my database and also see if they are a user or admin then set the session settings to user or admin. Problem is I have no idea how to wright this page.
-
Apr 12th, 2004, 03:28 AM
#5
All you need to do is create a script which you will include at the top of each PHP page yuo want authenticated before displaying it. This script - lets call it auth.php - will do the following:
- Check to see if the user has logged in. If not display a login page and exit the script.
- Check $_REQUEST variables for submitted username and password. If they are present do the following:
--- Check the details submitted match those in the database. If not display an error and exit.
--- Set a session variable to identify the user has successfully logged on. - Using the session variable set in the prvious step extract the users preferences from the database and set other script variables accordingly. E.g. admin variables / user varibles etc.
You can do all this quite easily using the PHP session functions and all you need to do is put the following line at the top of each page you want authenticated:
PHP Code:
<?php
require ('auth.php');
?>
If authentication fails then the rest of the script will never be executed.
-
Apr 12th, 2004, 07:29 PM
#6
Thread Starter
Frenzied Member
Originally posted by visualAd
All you need to do is create a script which you will include at the top of each PHP page yuo want authenticated before displaying it. This script - lets call it auth.php - will do the following:
- Check to see if the user has logged in. If not display a login page and exit the script.
- Check $_REQUEST variables for submitted username and password. If they are present do the following:
--- Check the details submitted match those in the database. If not display an error and exit.
--- Set a session variable to identify the user has successfully logged on. - Using the session variable set in the prvious step extract the users preferences from the database and set other script variables accordingly. E.g. admin variables / user varibles etc.
You can do all this quite easily using the PHP session functions and all you need to do is put the following line at the top of each page you want authenticated:
PHP Code:
<?php
require ('auth.php');
?>
If authentication fails then the rest of the script will never be executed.
Thanks man that's how I thought it would do, I just having problems getting started with it.
Could someone please post a If statement to see if a person has logged in?? the rest i might be able to work out
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|