| MyDomains.net Name: -Unknown- Location: Inside your head... Join Date: Oct 2005
Posts: 804
NP$: 42.70 ( Donate)
| The both cleaned-up and corrected version of that code, rewritten by NamePro's resident PHP guru SecondVersion. Hope this solves that issue for you. Thank You, SecondVersion PHP Code: <?php
$file = '/home/nonpubl/public_html/np/HTaccess-Sample/mylogins.txt';
if (!is_file($file))
{
die("$file does not exist.");
}
$contents = htmlentities(file_get_contents($file));
if (isset($_POST['submit_edit']) AND trim($_POST['edit']) != '')
{
$edit = trim(html_entity_decode($_POST['edit']));
$fp = fopen($file, 'w+');
fputs($fp, $edit);
fclose($fp);
}
?> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<textarea name="edit" cols="45" rows="20"><?php echo $contents; ?></textarea><br>
<input type="submit" name="submit_edit" value="Edit List">
<input type="button" value="Refresh List" onclick="javascript:window.location.replace('<?php echo $_SERVER['PHP_SELF']; ?>')">
</form><br><br>
<?php
$didadd = '';
if (isset($_POST['submit_add']))
{
$username = trim($_POST['user']);
$clearpassword = trim($_POST['pass']);
if ($username != '' AND $clearpassword != '')
{
$encryptedpassword = crypt($clearpassword, base64_encode($clearpassword));
$login = "$username:$encryptedpassword\n";
$handle = fopen($file, 'a');
fwrite($handle, $login);
fclose($handle);
$didadd = "<b>Login added to<br><font color=\"red\">$file</font></b><br><br>UserName: <font color=\"red\">$username</font><br>Password: <font color=\"red\">$clearpassword</font><br>Encrypted As: <font color=\"red\">$encryptedpassword</font><br><br>";
}
}
?> <table>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<table>
<tr>
<td>UserName: </td><td><input type="text" name="user"></td>
</tr>
<tr>
<td>Password: </td><td><input type="text" name="pass"></td>
</tr>
<tr>
<td colspan="2" align="center"><input type="submit" name="submit_add" value="Add User"></td>
</tr>
</form>
</table><br><br>
<?php
echo $didadd;
?>
__________________ ♥ In loving memory of my mother - Valettajho - Sept. 23, 2008 ♥
A devoted mother, sister, grandmother, great-granddaughter, and a true friend to anyone blessed enough to have met you. You taught me well, and made me who I am today. I can only hope to live the remainder of my life in a fashion that you would be proud of. Your life may have been taken by the hands of a man, but in doing so he delivered you into the hands of God. You will forever be missed. |