Home >Backend Development >PHP Tutorial >How to increase and decrease users in .htpasswd online in php

How to increase and decrease users in .htpasswd online in php

WBOY
WBOYOriginal
2016-08-08 09:34:051143browse

How to add or delete users in .htpasswd online in php

include("./class.Htpasswd.php3");

/* Please modify the path of this .htpasswd file
*/​
$htpasswdfile = "/usr2/amitc/.htpasswd";


// Please do not modify this line
echo '

';
?>










Username:
PassWord:

Verify Password

Add new user

Delete user

Change password





if(!isset($operation)) {
}
else {
echo "
";
echo "You have just performed this operation, please check

";
echo "You want to set the user $username and password $password = [$doop]
";
$handle = new Htpasswd($htpasswdfile);

switch ($doop) {
case 'add':
PRint "User
";
$retval = $handle->addUser($username, $password);
if($retval) {
print "User [$username] joined successfully!
";
} else {
print "Failed to join user [$username].
";
}
break;

case 'change':
print 'Change password
';
$retval = $handle->changePass($username, $password);
if($retval) {
print "[$username]'s password was changed successfully.
";
} else {
print "[$username]'s password modification failed.
";
}
break;

case 'delete':
print 'Delete user
';
$retval = $handle->deleteUser($username);
if($retval) {
print "[$username] was deleted.
";
} else {
print "An error occurred while deleting [$username].
";
}
break;

case 'verify':
print 'Code to verify user's password
';
$retval = $handle->verifyUser($username, $password);
if($retval) {
print "[$username] verifies okay with password [$password]
";
} else {
print "Verify Error for [$username] with [$password] (wrong password or user doesn't exist!)
";
}

break;

default:
print 'Do you want to interrupt?
';
}
echo "
";
}
?>

The above introduces how to add and delete users in .htpasswd online in PHP, including relevant content. I hope it will be helpful to friends who are interested in PHP tutorials.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn