Re: Editing Files with PHP
| From: | Richard Lynch | Date: | Wed, 11 Jul 2007 21:14:33 +0000 |
| Subject: | Re: Editing Files with PHP | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-258647@lists.php.net to get a copy of this message | ||
On Tue, July 10, 2007 7:33 pm, David Wonderly wrote:
> I am trying to create a small script to open a file and edit it.
> However, when I open a file with PHP in it the PHP is stripped out. It
> open as if I was viewing the page source. How do I fix this?
> Here is the code I am using.
>
> <form action="filewrite.php" method="post">
> <textarea rows="15" cols="70" name="content">
> <?php
> include($file) ;
include executes the PHP in the file.
readfile just reads it as-is
> ?>
> </textarea>
> <input type="text" name="filename" />
> <input type="submit" />
> </form>
>
> Filewrite looks like this
> <?php
> $File = $filename;
> $Handle = fopen($File, 'r+');
> $Data = $content;
> fwrite($Handle, $Data);
> fclose($Handle);
> print "Data Written.";
> ?>
> Like I said, it is very simple but, I can write php if I start with a
> blank page but, I can open a file and view it. All of the files are at
> david.wonderly.com
Your filewrite looks suspiciously like http://php.net/file_put_contents
:-)
--
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?