SoFunction
Updated on 2025-04-09

Create a Counter DIY Three Steps (Part 2)

In this article, I will introduce you to how to place counters on OSO on your mirror site. In this article, I will introduce you to the idea of ​​how to build your own free counter system. You have to write the program yourself.
Many websites provide free counter services. I had a long time ago, I had a dream to build my own free counter system. Now that OSO provides a database, all this will become a reality.
Most websites only provide free counters to members. We can also do this so that our website can also have some subjects. When they register, they can automatically generate an ID. Our counter system depends entirely on this ID!
When a user applies for a counter, the first thing is to check the user name and password. After logging in successfully, the user's ID is called out from the database. After the user applies, the system will automatically create two files and sums. The simple process can be as follows:
    $filea="count".$id."php";
    $fileb="show".$id."php";
    $fpa=fopen("count/$filea",w);
    $fpb=fopen("show/$fileb",w)
Then write the file, the content is similar to the one in the article. Just change the num. The simple process can be as follows:
    fputs($fpa,$count,strlen($count));
    fputs($fpb,$show,strlen($show));
Content in $count=;
Content in $show=;
This generates two files and lets the database insert num=id and finally returns a piece of code to let the user know how to use this counter and everything is done!
However, I think when applying for a counter, the user can set the initial value, and when inserting the database num, use replace to replace insert, so that if the user forgets the code, he can apply for one at any time and set the initial value. The counter will overwrite the original record, so there is no need to let the user remember the code or provide the code to return, which is too troublesome!
How about it? Everything is easy. I hope you can successfully build your own counter system through these three articles. I wish you success here!