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.
When I change the password, and logout of the site, the text file "textfile.t xt" becomes blank. Help anyone?
Code:
<?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><b>Your Password has<br>Been Updated</b></h1>";
Print "<br><br><br><br><br><br><hr>";
print "<A HREF='a4_main.php'>Return to Main Page</A> | <A HREF='a4.php'>Logout</A>";
// 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.t xt" becomes blank. Help anyone?
Comment