This is what I got from the net. Basically, what this do is after you hit submit, it will replace whatever is in the info.dat. What I want is instead of replacing what is in the info.dat, I want to put more
PHP Code:
<?
$newcontents="This
is my content"; //
$filename="info.dat";
$fp = fopen ($file_name, "w");
fclose ($fp);
chmod($file_name,0777);
?>
<html>
<head>
<title>File Editor Test</title>
</head>
<body>
<h1>File Editor Test</h1>
<?php
$newcontents = $contents;
if(isset($_POST['submit'])) { //if submit was pressed
$writefh = fopen($filename, "w"); //File handle for $filename
if(get_magic_quotes_gpc()){
$newcontents=stripslashes($_POST['editcontents']);
} //strips unneeded backspaces by magicquotes
else{
$newcontents = $_POST['editcontents'];
}
//NEXT 3 LINES ARE THE PROBLEM SPOT:
fwrite($writefh, $newcontents, strlen($newcontents)); //Saves changes
rewind($readfh); //resets cursor in file
echo("The changes were saved.<br/>\n");
fclose($writefh);
}
?>
Edit the file here:
<form method="post" action="<? echo($PHP_SELF); ?>">
<textarea name="editcontents" style="width:400px; height:150px;"><? echo($newcontents); ?></textarea>
<br />
<input type="submit" name="submit" value="Save Changes" />
</form>
</body>
</html>