Tracking users and passwords with a DBM database : DBM « MySQL Database « PHP






Tracking users and passwords with a DBM database

 
<?php
$user = $_SERVER['argv'][1];
$password = $_SERVER['argv'][2];

$data_file = '/tmp/users.db';

$dbh = dba_open($data_file,'c','gdbm') or die("Can't open db $data_file");

if (dba_exists($user,$dbh)) {
    print "User $user exists. Changing password.";
} else {
    print "Adding user $user.";
}

dba_replace($user,$password,$dbh) or die("Can't write to database $data_file");

dba_close($dbh);
?>
  
  








Related examples in the same category

1.Calculating password length with DBM
2.Storing structured data in a DBM database