Re: Unix passwd file
| From: | Josep R. Raurell | Date: | Fri, 04 Oct 2002 11:09:16 +0000 |
| Subject: | Re: Unix passwd file | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-118856@lists.php.net to get a copy of this message | ||
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