Not sure how I could do this as I could not find a functions on to
allow me to first delete the entire contents of a file "before" writting the
changes supplied by a textarea.  Here is what I have thus far:
Page one - Form:
$file_name = 'blank.php';
$open_file = fopen("$file_name","rw");
if (!$open_file) {
 die("cannot open $file_name");
 } else {
 $read_file = fread($open_file, filesize($file_name));
  $strip_php = eregi_replace("<","&a&", $read_file);
<form name="edit_passwords" method="post" action="edit_passwords.php">
  <textarea name="passwords" cols="60" rows="7"><?php echo $strip_php;
  <input type="submit" name="save" value="save">
Page two - open file and write changes:
if (!$passwords) {
 header ("Location: index.php");
 } else {
 $file_name= "blank.php";
 $file_open = fopen($file_name, "r+");
  eregi_replace("&a&","<", $file_open);
  #eregi_replace("\","", $file_open);
  fwrite($file_open, $passwords);
 print ("$passwords was written to $file_name"); }
As of right now it opens the file and writes your changes, however it simply
goes to the end of the file then begins writting.  I would like to delete
the contents of the file, then write the changes.
Any help or pointers are appreciated!

PHP General Mailing List (
To unsubscribe, visit:

Reply via email to