I need a login script to protect web page (very simple)

Discussion in 'Programming' started by Design1, Aug 30, 2010.

  1. #1
    I need a login script to protect web page (very simple). My problem is i need it to be compatible with as many browsers as possible. I have tried a few javascript password prompts that worked fine in everything but IE.

    All i need to do is password protect a web page, nothing fancy at all. Any suggestions?
    Thanks
     
    Design1, Aug 30, 2010 IP
  2. MyVodaFone

    MyVodaFone Well-Known Member

    Messages:
    1,048
    Likes Received:
    42
    Best Answers:
    10
    Trophy Points:
    195
    #2
    On your protected pages (php ?) write:
    
    require('login.php');
    
    PHP:
    Your login.php script:
    
    <?php
    
    $adminuser = "admin";
    $adminpass = "password";
    
    
    if(($_SERVER['PHP_AUTH_USER'] != $adminuser) || ($_SERVER['PHP_AUTH_PW'] != $adminpass)) {
    	header('WWW-Authenticate: Basic realm="Admin Mode"');
    	header('HTTP/1.0 401 Unauthorized');
    	echo "Wrong credentials!";
    	exit;
    }
    
    ?>
    
    PHP:
    That's it...
     
    MyVodaFone, Aug 30, 2010 IP
  3. Rainulf

    Rainulf Active Member

    Messages:
    373
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    85
    #3
    Try to protect it through .htaccess ;)
     
    Rainulf, Aug 31, 2010 IP
  4. ayman20068

    ayman20068 Well-Known Member

    Messages:
    273
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    185
    #4
    i have a few php log in codes , and i can help you in installing any if you like
     
    ayman20068, Sep 1, 2010 IP