#1
  1. No Profile Picture
    kumars
    Guest
    Devshed Newbie (0 - 499 posts)
    I am trying to use HTML's basic realm authentication scheme. Unfortunately either it ends up not allowing any one to get in or it let any body to get in.

    I have setup users to register themselves in a mySQL registration database. How can I check the entered password with the one in the database?

    I know the code is getting ugly since I have not much experience in using PHP.
    Can some one help...
    Here is the code ...

    Thanks

    <?php
    function authenticate() {
    Header( "WWW-authenticate: basic realm='My Authentication System'");
    Header( "HTTP/1.0 401 Unauthorized");
    echo "You must enter a valid login ID and password to access this resourcen";
    exit;
    }
    if (!isset($PHP_AUTH_USER) && !isset($PHP_AUTH_PW)&& !isset($userpasswd)){
    authenticate();
    }
    else {
    mysql_connect("localhost", "webuser", "");
    $query = "SELECT passwd from clients where userid = '$PHP_AUTH_USER')";
    $result = mysql_db_query("registration", $query);
    if ($result){
    while ($r = mysql_fetch_array($result)) {
    $userpasswd = $r["passwd"];
    }
    if(!($userpasswd == $PHP_AUTH_PW)){
    echo "Incorrect password THREE";
    exit;
    }
    elseif(empty($result)){
    echo "Incorrect password ONE";
    exit;
    }
    echo "Welcome: $PHP_AUTH_USER<BR>";
    echo "You have entered: $PHP_AUTH_PW<BR>";
    }
    } //end of function authenticate
    ?>
    <body bgcolor='lightyellow'>
    ...
  2. #2
  3. No Profile Picture
    kumars
    Guest
    Devshed Newbie (0 - 499 posts)
    Some more information:
    I have RedHat6.0 Linux 2.2.5, PHP3 and is compiled with Apache3.3.x, mySQL.

    Kumarsv
    www.pricelane.com

Similar Threads

  1. Authentication System
    By ThundaCat in forum PHP Development
    Replies: 5
    Last Post: January 31st, 2004, 01:32 PM
  2. password generation on user auth.
    By nacho_c in forum PHP Development
    Replies: 14
    Last Post: January 16th, 2004, 04:55 AM
  3. Replies: 1
    Last Post: January 7th, 2004, 06:41 PM
  4. PHP Gameserver-booking system
    By Skaven in forum Project Help Wanted
    Replies: 0
    Last Post: January 3rd, 2004, 07:20 PM
  5. want password protect?
    By CaptinKirk in forum Beginner Programming
    Replies: 4
    Last Post: December 18th, 2003, 12:00 PM

IMN logo majestic logo threadwatch logo seochat tools logo