Skip navigation
Currently Being Moderated

Modifying browser's user/pass dialog?

Jul 30, 2012 9:26 AM

Tags: #.htaccess

In my web site, I have an area(directory) that is password protected via an .htaccess file. So when I am linking to files inside that directory I get the browser default user/password dialog. I am wondering if there is any way to modify this dialog? I would like to change the copy inside of it, add a button and link to another page. The issue is basically that the client wants to point out a way to get the user and pass for people that don't have it. 

 

Is this possible? What other options do I have with this dilema?

 

Thanks a lot!

 
Replies
  • Currently Being Moderated
    Jul 30, 2012 9:41 AM   in reply to brian914

    You can't change the browser default. You'll need to create a separate log-in form outside the protected folder.

     

     

    Nancy O.

     
    |
    Mark as:
  • Currently Being Moderated
    Jul 30, 2012 10:24 AM   in reply to brian914

    All depends on where you store the user names and passwords and how much security you need. 

     

    A good place to start might be with David Powers' Tutorial.

     

    "Building your first dynamic website – Part 1: Setting up your site and database connection"

    http://www.adobe.com/devnet/dreamweaver/articles/first_dynamic_site_pt 1.html

     

     

    Nancy O.

     
    |
    Mark as:
  • Currently Being Moderated
    Aug 1, 2012 9:29 AM   in reply to brian914

    Do you have the use of php? If so below is a simple login that can be styled to suit yourself. Additional usernames/passwords can be added if necessary but once you get beyond a certain amount it's best to store the information in a database. This solution will suit a dozen or so usernames/passwords. The username at the moment is "Pink" and password is "Elephant". You can change those in the php code below, also change the 'Location' url of the protected page to be taken to if the user supplies the correct combination

     

    The form 'action' points to the page where you insert the form. So if you include the form on a page called no_database.php that's where the form sends the form information to be processed (obviously the php must be included at the top of that page as well)

     

    <?php

    if (array_key_exists('login', $_POST)) {

    $username = $_POST['username'];

    $password = $_POST['password'];

     

    if($username == "Pink" && $password == "Elephant") {

                header("Location: http://www.bbc.co.uk"); }

                else {

                    $passError = "<h2>Incorrect Username or Password</h2>";

                }

    }

     

    ?>

     

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

    <html xmlns="http://www.w3.org/1999/xhtml">

    <head>

    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />

    <title>Untitled Document</title>

    </head>

     

    <body>

    <form action="no_database.php" method="post">

    <p>Username<br />

    <input name="username" type="text" /></p>

    <p>Password<br />

    <input name="password" type="text" /></p>

    <label for="button"></label>

    <input type="submit" name="login" id="login" value="Login" />

    </form>

    <?php

    if(isset($passError)) {

        echo $passError;

    }

    ?>

    </body>

    </html>

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points