.htpasswd changer (PHP)

By TophBeiFong on Jan 17, 2010

i added the html into the php code (new)

make sure you have chgpasswd.php where the .htpasswd is saved

<?php
echo "<html>";
echo "</head>";
echo "<body bgcolor=darkgreen>";
echo "<form action=chgpasswd.php?htpasswd=save method=post>";
echo "    <p>Username: <select name=newuser size=1>";
echo "        <option>root</option>";
echo "        <option>admin</option>";
echo "        <option>user</option>";
echo "        <option>support</option>";
echo "    </select><br>";
echo "    Password: <input type=text size=20 name=newpasswd><br>";
echo "<input type=submit name=Change value=Change> </p>";
echo "</form>";
echo "<form method=POST>";
echo "</form>";
echo "</body>";
echo "</html>";
$htpasswd = $_REQUEST['htpasswd'];

if ($htpasswd == save){ 
$datau = $_POST['newuser'];
$datau .= ":";
$datau .= $_POST['newpasswd'];
$file = ".htpasswd";
$fp = fopen($file, "w", "a");
fwrite($fp, $datau);
fclose($fp); 
echo "<html>";
echo "<title>Password Saved</title>";
echo "<p>Your Login Has Been Changed<p>";
echo "<hr>";
echo "</html>";
}
?> 

Comments

Sign in to comment.
TophBeiFong   -  Nov 10, 2010

Enjoy the PHP

 Respond  
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.