I found this code in a web (or somthink like this), but can remever 
where to give the credits, sorry.


include_once('/etc/php/bases.php');
function autentifica($user,$pass)
{
    global $db1Host, $db1User, $db1Pass;

    $auth = false;
    mysql_connect($db1Host,$db1User,$db1Pass)
      or die ('Unable to connect to server.');
    // Select database on MySQL server
    mysql_select_db('mysql')
      or die ('Unable to select database.');
    // Formulate the query
    $sql = "SELECT user FROM user WHERE User='$user' && 
password=PASSWORD('$pass')";
    // Execute the query and put results in $result
    $result = mysql_query($sql)
        or die ('Unable to execute query.');
    // Get number of rows in $result.
    $num = mysql_numrows( $result );
    if ($num != 0) {
    // A matching row was found - the user is authenticated.
            $auth = true;
    }
    return $auth;
}

Josep R. Raurell


En/na Scott ha escrit:

>I apologize if this is might be OT.  I have 5,000+ users in a unix passwd 
>file that I would like to move to a MySQL table to build a login system 
>with php.  I could then use this table for Postfix and Radius.  I know 
>about the getpwent in perl, but does anyone know if I populate a MySQL 
>table with the login/password can php then use that encrypted password to 
>validate users?
>
>TIA
>
>
>  
>




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to