writting to files
| From: | Jas | Date: | Fri, 31 May 2002 20:34:47 +0000 |
| Subject: | writting to files | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-100167@lists.php.net to get a copy of this message | ||
Ok, I have been working on this for awhile and cannot seem to get the fwrite
function to work. Here is the code:
\\ index.php
<?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>
This works as I need it to, opens the file and then removes the first < so
that it won't be parsed as a php script.
\\ edit_passwords.php
<?php
if (!$passwords) {
header ("Location: index.php");
} else {
$file_name= "blank.php";
$file_open = fopen($file_name, "rw");
fwrite($file_open, $passwords);
print ("$passwords was written to $file_name"); }
?>
I have read and write permissions set on the file and the directory. It
will not write changes to the file. Any pointers?
Jas