I'm trying to set up a basic username/password login page and changing the password via writing back to a text file. Here is the code for the page:
<?php
//Confirmation for Changed Password
// Retrieve lists of username and password session variables
session_start();
$u_list = $_SESSION["u_list"];
$p_list = $_SESSION["p_list"];
print "<html>";
print "<body>";
print "<BODY bgcolor='#66ff66'>";
print "<center>";
print "<h1>Your Password has
Been Updated</h1>";
print "
";
print "<A HREF='a4_main.php'>Return to Main Page[/url] | <A HREF='a4.php'>Logout[/url]";
// Write lists of usarnames and passwords (with new password) back to text file
$fp = fopen("textfile.txt", "w");
for ($x=0; $x<count($u_list); $x++)
{
fputs($fp,$u_list);
fputs($fp,"\n");
fputs($fp,$p_list);
fputs($fp,"\n");
}
fclose($fp);
print "</body>";
print "</html>";
?>
When I change the password, and logout of the site, the text file "textfile.txt" becomes blank. Can't log in at all without uploading the original text file back to the server. Help anyone?