Page opening status prompt

Source: Internet
Author: User
When the page is opened, the system prompts that an information management page is written. because there are multiple operations, sometimes two people open the same information at the same time, I want to make a status prompt. if one person has already opened this page and another person has opened it, a prompt will be displayed indicating that someone is operating on it. please try again,


Reply to discussion (solution)

In general, it is locking.
As for how to add, it depends on the business and implementation.

You can lock files.

In general, it is locking.
As for how to add, it depends on the business and implementation.

You can lock files.

Is the table locked? In this way, the information in the same table cannot be operated by others. can we lock only one entry in the table?

How to lock a row-table database

LockThere are multiple forms to choose based on the implementation of your business logic.

The table lock and record lock you mentioned cannot be used in your scenario. they are only valid in the same database connection.

LockThere are multiple forms to choose based on the implementation of your business logic.

The table lock and record lock you mentioned cannot be used in your scenario. they are only valid in the same database connection.

I use the label to pass the id. if someone is already operating on this id, someone else will be prompted to operate on this link.
[Code = php] ["> modify/code]
Prompt how to write the class

When the object is locked, false is returned when the object is operated. you can determine the value through the return value;

Lock. php
$ Fo = fopen('abc.txt ', 'R + ');
Flock ($ fo, LOCK_EX );
Sleep (10 );
Flock ($ fo, LOCK_UN );
?>

Read. php
$ Fo = fopen('abc.txt ', 'R + ');
If (! $ A = fgets ($ fo )){
Echo "operations performed by existing users ";
}
Else {
Echo $;
};
?>

Add a flag. for example, if zyflag 0 is added to the table, it indicates that 1 is not used. if it is used, it is set to 1. if it is disabled, it is set to 0.

The above file lock or cache lock is better
This is because when you open the page, you can directly determine the file and cache to see if anyone is using it.

Khmod. php

If (file_exists ('lock /'. $ _ GET ['id']) die ('existing operator '); file_put_contents ('lock /'. $ _ GET ['id']); // Here is the original code unlink ('lock /'. $ _ GET ['id']);

Khmod. php

If (file_exists ('lock /'. $ _ GET ['id']) die ('existing operator '); file_put_contents ('lock /'. $ _ GET ['id']); // Here is the original code unlink ('lock /'. $ _ GET ['id']);

Lock/Is this the path?
According to the code, if the user just opens the page and exits without any operation, the user will always be prompted to perform operations.

Yes.
This is the sequent of locking. when it appears, it can only be unlocked by the administrator.

Based on your business scenario, you can use session or cookie to determine whether the page has been opened and give a flag to determine.

Based on your business scenario, you can use session or cookie to determine whether the page has been opened and give a flag to determine.
You cannot operate cookies on different computers.
How should we judge the session?

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.