Results 1 to 6 of 6

Thread: Login Page

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Jun 2003
    Location
    Auckland
    Posts
    1,139

    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.

  2. #2
    <?="Moderator"?> john tindell's Avatar
    Join Date
    Jan 2002
    Location
    Brighton, UK
    Posts
    1,099
    you could use session to store if they are logged in or not

    PHP Code:
    if(empty($_SESSION['loggedin'] )){
         
    header('Location: login.php');


  3. #3
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    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?
    My evil laugh has a squeak in it.

    kristopherwilson.com

  4. #4

    Thread Starter
    Frenzied Member
    Join Date
    Jun 2003
    Location
    Auckland
    Posts
    1,139
    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.

  5. #5
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Ickenham, UK
    Posts
    4,906
    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.
    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

  6. #6

    Thread Starter
    Frenzied Member
    Join Date
    Jun 2003
    Location
    Auckland
    Posts
    1,139
    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
  •  



Click Here to Expand Forum to Full Width