It is better and clever to edit in a file instead of a database in numerous cases… It is even smoother and quite often faster! We can edit not only in a txt file but also in a php, asp, or html file, and that is very interesting!!! to create new web pages right on demand that will be addressed directly!
How to do it?
With ASP, you must get a folder that is not protected for editing (ask the ISP administrator to open it)
After that,
create an object such as Scripting.FileSystemObject
<% Set FSO = _ Server.CreateObject("Scripting.FileSystemObject") %>
Collect the long path of the folder that contains the file
<% dir = Server.MapPath("my_folder/") %>
Wrtite the complete path of the file
<% Fnm = dir & "\my_file.ext" %>
Be aware of \
Create the file and open it at the same time!
<% set inF = FSO.CreateTextFile(Fnm) %>
or, open it in editing mode
<% set inF = FSO.OpenTextFile(Fnm,2,false) %>
or, finally open it in "append" mode editing at the end
<% set inF = FSO.OpenTextFile(Fnm,8,false) %>
If 'true' replaces 'false' a file will be automatically created if it does not exist... so, be careful!
Then, simply write
<% inF.write texte %>
or, write a line add VbCrLf at the end of the text
<% inF.writeLine texte %>
or, write some empty lines
<% inF.writeBlankLines(5) %>
And, finally close the file
<% inF.close %>
With PHP, it is fundamental to be sure that editing function is authorized with the folder (chmod or via FTP software)
After that,
Define the file of interest
<? $Fnm = "my_folder/my_file.ext"); ?>
Open the file in editing mode create if it does not exist
<? $inF = fopen($Fnm,"w"); ?>
or, in "append" mode Create if it does not exist
<? $inF = fopen($Fnm,"a"); ?>
or, in "mixte" mode reading and editing
<? $inF = fopen($Fnm,"r+"); ?>
Eventually, point out the cursor
The position of the cursor is in:
<? $ptr = ftell($inF); ?>
and, you can modify it by typing:
<? $ptr = fseek($inF,$ptr-10); ?>
Then, simply write
<? fwrite($inF,$texte); // or fputs($inF,$texte); ?>
If you have well assimilated this presentation and the other ones, you should be able to produce something like this! If not, see detailed explanations here in...