Answer the question
In order to leave comments, you need to log in
Access to a page with a script from different computers?
Hello.
A question.
There is a php script. It doesn't matter which one, it's not the point.
If it is executed for one user, then:
If another user logs in at the same time, he will see the result of the script execution, the user who logged in before him! This is natural since it is not js that is executed for every browser.
And how can I make it so that the php script is executed for each user. So that they do not see the results of each other's script! Without registration and database.
The script is that there is a record in a file.
Answer the question
In order to leave comments, you need to log in
As already mentioned above, the PHP script is re-executed on each request, users do not see the result of another user's execution, only if these results were not saved and intentionally displayed.
If I understand correctly, your problem is that PHP writes something to a file and shows it. Since there is only one file, all users see it in full. If you need to change this behavior, then you need to do 2 things: 1 - distinguish users from each other, 2 - mark the stored data, which user it belongs to.
You can distinguish users in different ways, the most logical way to do this is with the help of sessions: php.net/manual/ru/session.examples.basic.phpbut depending on the task, this can be done in other ways, for example, by the user's IP or other information.
If you absolutely must store data in files, then it's probably best for each user to create their own file. If the file must be one, then it is most convenient to use one of the formats: CSV, JSON or XML. In this case, the file will store both data and a label indicating which user this data belongs to.
But all these options are not convenient for active work with data and are not suitable for storing a large amount of data for a large number of users. The best option would still be to use a database, you may be interested in the SQLite DBMS, it does not need a server, all data is stored in one file.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question