Forum Moderators: coopster
$any = "@,@";
$filename="mydata.txt"; //sets file to edit
$handle = fopen($filename, 'r+'); //File handle for $filename
if(isset($_POST['Submit'])) {
{
while(1) {
$line = fgets($handle); //read line from file content
if($line == null)break; //if end of file reached then stop reading
anymore
$newcontents = trim(addslashes($_POST['Name'])).$any.addslashes($_POST['Address']).$any.addslashes($_POST['Area'])."\r\n";
$str.= $line; //set file content to a string
}
}
$str.= $newcontents; //append new updated contents to file content
rewind($handle); //set pointer back to beginning.
ftruncate($handle, filesize($filename)); //delete everything in the file.
fwrite($handle, $str);//write everything back to file with the updated contents.
echo '<script>alert("Reseller Updated !");opener.location.reload();</script>';
echo '<script>window.close();</script>'; exit();
fclose($handle);
}
$any = "@,@";
if(isset($_POST['Submit']))
{
$filename="mydata.txt"; //sets file to edit
$handle = fopen($filename, 'r+'); //File handle for $filename
$newcontent = trim( addslashes($_POST['Name'])) . $any.addslashes($_POST['Address']) . $any.addslashes($_POST['Area']) . "\r\n";
$current_content = '';
while( !feof( $handle ) )
{
$line = fgets( $handle );
// if eof ( end of file then the last line shouldn't be written back!
if( !feof( $handle ) )
{
$current_content .= $line; //set file content to a string
}
}
fclose( $handle );
$current_content .= $newcontent; //append new updated contents to file content
$handle = fopen($filename, 'w+'); //File handle for $filename writing
fwrite($handle, $current_content); //write everything back to file with the updated contents.
fclose($handle);
echo '<script>alert("Reseller Updated !"); opener.location.reload(); </script>';
echo '<script>window.close();</script>';
}