+ Reply to Thread
Results 1 to 3 of 3
Like Tree2Likes
  • 2 Post By KSclans

Thread: login with header("WWW-Authenticate: Basic realm=\"example\"");

  1. #1
    Join Date
    Oct 2007
    Location
    IN YOUR FACE
    Posts
    341

    login with header("WWW-Authenticate: Basic realm=\"example\"");

    I know this is a stupid way of making a login script but...

    if the user name is "bob" and the password is "x10", a file exists in Accounts/ Called Bob.txt with the value "x10"

    How can I make a login with that and: header("WWW-Authenticate: Basic realm=\"example\"");

  2. #2
    KSclans is offline x10 Sophmore KSclans is an unknown quantity at this point
    Join Date
    Nov 2007
    Posts
    198

    Re: login with header("WWW-Authenticate: Basic realm=\"example\"");

    you can use

    $file=fopen("welcome.txt","r") or exit("Unable to open file!");

    well if you have a html form then put a varibale or $POST_login or something like that

    and I need to do some research on the value x10 one edit post later....

    ____
    Edit:

    so fopen will open your file and give permission to read that what "r" stand for Read... and use fread to display data if you only have the password or it will display all the content it have... so like

    $fopen = fopen($text, 'r');
    $password = fread($fopen);
    and then the $password should have the password but $text need to be the file like bob.html in order to read the file...

    but if you really put your password there people can just go to bob.html and see the password...I don't know why you doing it so I can't tell you exactly what you want.
    Last edited by KSclans; 11-16-2008 at 12:42 AM.
    dinomirt96 and karimirt47 like this.

  3. #3
    mfurqanabid's Avatar
    mfurqanabid is offline x10Hosting Member mfurqanabid is an unknown quantity at this point
    Join Date
    Mar 2008
    Posts
    37

    Re: login with header("WWW-Authenticate: Basic realm=\"example\"");

    function runHeader(){
    header('WWW-Authenticate: Basic realm="Example"');
    header('HTTP/1.0 401 Unauthorized');
    include("access_denied.php");
    die();
    }

    $posFile = $_SERVER['PHP_AUTH_USER'] . ".txt";
    if (file_exists("/userfile/" . $posFile)){

    $file=fopen($posFile,"r");
    $pass = fread($file, filesize("/userfile/" . $posFile));
    fclose($file);

    if ($pass!=$_SERVER['PHP_AUTH_PW']){
    runHeader();
    }else{
    //Run Code if Valid User Here
    }

    }else{
    runHeader();
    }
    Edit:
    This will fulfill your need.
    Last edited by mfurqanabid; 11-22-2008 at 03:49 AM. Reason: Automerged Doublepost

+ Reply to Thread

Similar Threads

  1. phpBB3 external login
    By caiol611 in forum Programming Help
    Replies: 11
    Last Post: 04-27-2008, 08:22 PM
  2. The previous way of login?
    By halchalgroups in forum Free Hosting
    Replies: 1
    Last Post: 09-22-2007, 02:07 AM
  3. A simple Visual Basic Login Form
    By Zenax in forum Tutorials
    Replies: 0
    Last Post: 03-13-2007, 08:59 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers