SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Member
    Join Date
    Oct 2004
    Location
    pp
    Posts
    5
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    bypass .htaccess login box

    Hello,

    Is there a way in php that can be used to suppress the .htaccess login pop up? I mean I'd rather use my own login form and still need the directory protection at the server level.

    I use Apache 2.0.48, PHP 4.3.8.
    Thanks

  2. #2
    Obsessive designer Infizi's Avatar
    Join Date
    May 2004
    Location
    North Pole
    Posts
    450
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    umm,

    try something like this
    Quote Originally Posted by PHP.NET
    PHP Code:
    <?php
      
    function authenticate() {
       
    header('WWW-Authenticate: Basic realm="Test Authentication System"');
       
    header('HTTP/1.0 401 Unauthorized');
       echo 
    "You must enter a valid login ID and password to access this resource\n";
       exit;
      }
     
      if (!isset(
    $_SERVER['PHP_AUTH_USER']) ||
         (
    $_POST['SeenBefore'] == && $_POST['OldAuth'] == $_SERVER['PHP_AUTH_USER'])) {
       
    authenticate();
      } 
      else {
       echo 
    "<p>Welcome: {$_SERVER['PHP_AUTH_USER']}<br />";
       echo 
    "Old: {$_REQUEST['OldAuth']}";
       echo 
    "<form action='{$_SERVER['PHP_SELF']}' METHOD='post'>\n";
       echo 
    "<input type='hidden' name='SeenBefore' value='1' />\n";
       echo 
    "<input type='hidden' name='OldAuth' value='{$_SERVER['PHP_AUTH_USER']}' />\n";
       echo 
    "<input type='submit' value='Re Authenticate' />\n";
       echo 
    "</form></p>\n";
      }
    ?>

  3. #3
    SitePoint Wizard silver trophy someonewhois's Avatar
    Join Date
    Jan 2002
    Location
    Canada
    Posts
    6,364
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP is server side, so your own login is server side...

  4. #4
    SitePoint Member
    Join Date
    Oct 2004
    Location
    pp
    Posts
    5
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    bypass .htaccess login box

    hello brother,
    I want to protect my directory by using .htaccess. and use my own login box to log in to that direcotry.

    I don want to use the browser login b

  5. #5
    SitePoint Wizard silver trophy someonewhois's Avatar
    Join Date
    Jan 2002
    Location
    Canada
    Posts
    6,364
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Why not write your own authentication script though? It'd be your own form, and it'd log into the directory (effectively), and it's still server side.


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
  •