Use a text file to create a message board prompt (on ). The first is to ensure that text files can be read and written. before preparing to write files, all we need to do is to handle user messages! This work can be done before submitting the form. The first thing we get is to ensure that the text file can be read and written. before writing the file, all we need to do is to process the user's message!
This can be done before submitting a table. we separate the obtained data items with specific symbols, for example, using the & sign, it is worth noting that if the submitted data contains a specific character, we have to convert it into other forms. you have your own solutions;
If we get the data, such:
$ Str = "aaaaa & bbbbb & ccccc & ddddd ";
Before writing data to a file, we add
$ Str = $ str. "\ r \ n"
Then execute:
$ Fp = fopen ("txt/mytxt.txt", "");
Fwrite ($ fp, $ txt );
Fclose ($ fp );
In this way, the data we write is located at the end of the file.
How can we make the latest messages appear at the top of the message board?
With the above data processing, it is easy to handle,
$ Date = file ("txt/mytxt.txt ");
$ N = count ($ date );
For ($ I = $ n; $ I> 0; $ I --){
$ Str = explode ("&", $ date [$ I])
.
// Outputs the $ str array.
.
}
In this way, the newly inserted messages are kept in the first place.
Success! This can be done before submitting the table. we will get the data...