newbie! Editing text files with 2 PHP Scripts - HELP!


I’m setting up a simple way to amend text files on a server to be used within a site.
There are 3 text files at present I would like to be able to amend, but plan to increase this and just change the links as I go on.

I am using the code below from

I have setup a simple HTML page which defines links to for each text file to amend and send a $file variable to the “form.php” script, but I cant get the $file variable to continue over to the 2nd php script “process.php” to update the text file for that variable.

Is there some way of keeping the $file variable available in memory or something to use in the “process.php” script on submit??

Can anyone help me with this??? I’m tearing my hair out!!!

Thanks in advance.

WEB PAGE HTML file is…

Test Text 1

Test Text 2

Test Text 3

FORM.PHP script content is…

<? print htmlspecialchars(implode("",file($file))); ?>

PROCESS.PHP script content is…

<? $_GET['file'] $content = stripslashes($_POST['content']); $fs = fopen($file,"w") or die ("Error opening file!"); fputs($fs,$content); fclose($fs) or die ("Error closing file!"); echo ""; ?>


Well, you are linking to just plain “process.php” - nothing in the querystring. I would suggest that if you want to $_GET the $file from the querystring you add it to the querystring in form.php.

I am understanding you correctly… You wish to pass a variable over multiple pages??? check out session variables and cookies.

Sponsor our Newsletter | Privacy Policy | Terms of Service