Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5

Thread: Authentication

  1. #1
    New Coder
    Join Date
    Feb 2004
    Posts
    17
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Authentication

    Hi guys,

    I have a question.

    I'm thinking of creating a folder called 'client', which have several other folders based on usernames. These other folders will be password protected through their own .htaccess and .htpassword files
    And in this client folder, i'll have an index page. In this index page there'll be a form asking for the username.

    My question is, how do I make it so that when they submit that username they'll be taken to their own respective folder (so www.domain.com/client/username) and a pop-up that appears because of the .htaccess will have their username typed in automatically?

    Or is there another approach to this?

    I'm open to any suggestions.

    All help will be greatly appreciated.

    Thank you =).

  • #2
    Regular Coder
    Join Date
    Sep 2002
    Location
    Scotland
    Posts
    407
    Thanks
    0
    Thanked 0 Times in 0 Posts
    surley you could just use a simple IF/THEN/ELSE loop?

    example:

    PHP Code:
    if ($user=="penguinjr")
    {
        include(
    'penguin/index.php'); #path for penguinjr's folder
    }
    elseif (
    $user=="sweenster")
    {
        include(
    'sweenster/index.php'); #path for sweenster's folder
    }
    elseif (
    $user=="abcd")
    {
        include(
    'abcd/index.php'); #path for abcd's folder
    }
    else
    {
    die(
    'invalid user name');

    My body's a temple... and like those ancient Greek ones it's a ruin
    sweenster.co.uk

  • #3
    New Coder
    Join Date
    Feb 2004
    Posts
    17
    Thanks
    0
    Thanked 0 Times in 0 Posts
    That works fine.. for small number of users.

    What if there are 100 of clients? or even more?

    And does that automatically fill in the 'username' field for the authentication pop-up?

    I'd need something more flexible...

    Thanx anywayz =)

  • #4
    Super Moderator
    Join Date
    May 2002
    Location
    Perth Australia
    Posts
    4,073
    Thanks
    11
    Thanked 98 Times in 96 Posts
    PHP Code:
    assuming $user is authenticated at this point
    <?php
    if(file_exists($user.'/index.php')){
       
    header("location: $user/index.php");
      exit();
    }
    ?>
    resistance is...

    MVC is the current buzz in web application architectures. It comes from event-driven desktop application design and doesn't fit into web application design very well. But luckily nobody really knows what MVC means, so we can call our presentation layer separation mechanism MVC and move on. (Rasmus Lerdorf)

  • #5
    New Coder
    Join Date
    Feb 2004
    Posts
    17
    Thanks
    0
    Thanked 0 Times in 0 Posts
    thanx for the help guys =).


  •  

    Posting Permissions

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