Not sure how I could do this as I could not find a functions on php.net 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:
<?php
$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);
  fclose($open_file);
 }
?>
<form name="edit_passwords" method="post" action="edit_passwords.php">
  <textarea name="passwords" cols="60" rows="7"><?php echo $strip_php;
?></textarea>
  <br>
  <input type="submit" name="save" value="save">
</form>
Page two - open file and write changes:
<?php
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!
Jas



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to