Results 1 to 3 of 3

Thread: .htaccess login question

  1. #1
    Join Date
    Feb 2007
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default .htaccess login question

    Hello,

    Right now I am using a perl script for logins on my website. I have an html login page with a form. Everyone uses the same login page, but depending on the password they type in, they are sent to the respective page declared in the perl script.

    I just had some changes on my web hosting package and my .htaccess has been enabled. I wanted to use .htaccess for logins instead of the perl script.

    All I know so far about .htaccess is that it requires a link to the specific page and then displays a popup asking for the username and password. Fine, but I want a master login page that acts as mentioned above. Is there a way to achieve this?

    I've heard that Javascript can achieve an html login page, but I haven't found anything about a "master" login page.

    Thank you.

  2. #2
    Join Date
    Aug 2005
    Location
    Other Side of My Monitor
    Posts
    3,494
    Thanks
    5
    Thanked 105 Times in 104 Posts
    Blog Entries
    1

    Default

    Nothing I have found with .htaccess yet. I went looking for the same thing before.

    The best I could do was using php to accomplish the "master log in"

    here is an example page with such a log in. You can see the problems with too many different redirects

    PHP Code:
    <?php
    if($_POST['user']) {
    if((
    $_POST['user'] == "John") && ($_POST['pass'] == "Doe")) header("Location: /JohnDoe/");
    else if((
    $_POST['user'] == "Jane") && ($_POST['pass'] == "Doe")) header("Location: /JaneDoe");
    else 
    header("Location: wrong.htm");
    } else {
    ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html>
    <head>
    <title>Log In</title>
    </head>
    <link rel="stylesheet" type="text/css" href="/css.css" />



    <body>
    <br><br>
    <center>
    <font size= "6">Please Log In Below:</font><br><br><br>
    <form action="<?=$PHP_SELF?>" method="post">
    <p>Username: <input type="text" name="user"/>
    Password: <input type="password" name="pass"/>
    <input type= "submit" value= "Log In"/></p>
    </form>
    </center>
    </body>
    </html>
    <?php ?>
    Basically if Username == John, AND password == Doe, then they are redirected to folder named /JohnDoe/

    Like wise for user == Jane and password == Doe

    anything else will result in a redirection to page named wrong.htm

    Hope the idea helps.

    I am also working on a php log in that will ALSO prevent direct access to the files/folders through the URL. I have a working example, somewhere, I just have to find it again
    {CWoT - Riddle } {Freelance Copywriter} {Learn to Write}
    Follow Me on Twitter: @InkingHubris
    PHP Code:
    $result mysql_query("SELECT finger FROM hand WHERE id=3");
    echo 
    $result

  3. #3
    Join Date
    Feb 2007
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    That is basically what my perl script does. It works quite well, I just wanted to use .htaccess. Thanks for responding!

Bookmarks

Posting Permissions

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