SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Evangelist rhysboy84's Avatar
    Join Date
    May 2007
    Colwyn Bay, North Wales, UK
    0 Post(s)
    0 Thread(s)

    Newbie: Looking for some help building a login form

    Hi everybody!

    I'm playing around with PHP & MySQL at the moment, and am trying to learn various ways to do things and hopefully - in time - build up an application.

    What I'm trying to do (more because a mate wanted one, and I want to see how they work), is creating a login form. The form will check a database for values for username and password, and if they match the result from the login form, they'd allow you into the directory (say "admin").

    Now I can create said login form to check for the variables if there is a admin/login.php form. However, any other file in the admin/ directory is visible anyway, login form or not.

    Any help on how to create it (tutorials mainly) would be greatfully appreciated!

    I'm Rhys Wynne & I blog at Winwar Media
    WP Email Capture: Free Email/Ebook Marketing Wordpress Plugin
    UK Based SEO? Tweet Your Location to #ukseohere!
    | My Brand New Brand | Twitter |

  2. #2
    Follow Me On Twitter: @djg gold trophysilver trophybronze trophy Dan Grossman's Avatar
    Join Date
    Aug 2000
    Philadephia, PA
    1 Post(s)
    0 Thread(s)
    The basic idea is to put a snippet at the top of each page you want to protect like this:

    PHP Code:
    if (!isset(
    $_SESSION['logged_in'])) {
    header("Location: login.php");
    Your login script sets that session variable. Then any request to any protected page will redirect to the login form if the user is not logged in.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts