Read/Modify Files with a form

They have: 9 posts

Joined: Jun 2000

I'm looking for a script that places the input of a form to a html file but I should be able to "read" the html file again with the script and add/remove some entries of it. I'm quite new with CGI and I don't know if this is possible. Could you please help me?
Thanks

Dieter

Ken Elliott's picture

They have: 358 posts

Joined: Jun 1999

I have created similar scripts recently and the method that I use is to open the file that is to be edited into a textfield.

print "<form method=\"POST\" action=\"cgi-bin/addpage.cgi\">";
print "<textarea name=\"page\">";
open (PAGE, "< ../page.html");
@contents = <PAGE>;
close (PAGE);
foreach $line(@contents) {
print "$line";
}
print "</textarea>";
print "<input type=\"submit\">";

This code will open the specified page into the forms textarea for editing. Then you have a form which I named "addpage.cgi" that will parse the form input and recreate the page overwriting the old contents.

I don't know of a script in any of the resources that will do what you need. If I did I wouldn't have created my own .

Hope that helps some.
VulKen
Numero Uno

Pimpin like a pimp with an electrofied pimpin machine!

They have: 9 posts

Joined: Jun 2000

thanks, i'll check it out right away

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.