Hi,
I am having a problem writing to a file. I can actually get the code to write to the intended file, but it overwrites the first entry in the text file. I am not quite sure what is happening. If anyone can look this over, and offer any suggestions, that would be great..Thanks in advance.
Here is the text file before the php adds it content:
#
mike Password = "mike"
Service-Type = Framed-User,
Idle-Timeout = 1800,
Framed-Routing = None,
Framed-Filter-Id = "std.ppp"
#
dan Password = "dan"
Service-Type = Framed-User,
Idle-Timeout = 1800,
Framed-Routing = None,
Framed-Filter-Id = "std.ppp"
Here is the code I am using to add to the file.
<?
If ($submit)
{
If (!$file=fopen("users", "r+"))
{
echo "could not open file";
}
else
{
If (!$fout = fgets($file,3))
{
echo "could not perform fgets function";
exit();
}
$text = "#\n";
$text .= "".stripslashes($user);."password = \"".stripslashes($password);."\"\n";
$text .= " Service-Type = Framed User,\n";
$text .= " Idle-Timout = 1800,\n";
$text .= " Framed-Routing = None,\n";
$text .= " Framed-Filter-Id = \"std.ppp\"\n";
$text .= "#";
$text .= "#\n";
If(!$fout = fputs($file, $text))
{
echo "could not write to file";
exit();
}
fclose($file);
}
}
?>
And here is the text file after the php insert.
#
mike Password = "mike"
Service-Type = Framed-User,
Idle-Timeout = 1800,
Framed-Routing = None,
Framed-Filter-Id = "std.ppp"
#
Password = "dan"
Service-Type = Framed-User,
Idle-Timeout = 1800,
Framed-Routing = None,
Framed-Filter-Id = "std.ppp"
What's happening, is it adds the new entry in, but overwrites the first entry and takes out the name of the individual on the next line...?? Any suggestions?