当某些用户已经访问某个页面时,阻止访问或禁用该页面中的某些功能

Prevent access or disable some function in a certain page when some user already accessing

本文关键字:访问 功能 用户      更新时间:2023-11-13

我想在远程用户当前访问某个页面时禁用一些功能,如隐藏提交按钮,以防止重复工作。我的想法是创建一个助手,但我不知道如何实现它

 <?php
     function isLock() {
          //disable submit button if a user currently accessing it
      }
      function unLock() {
          //re enable submit button if no user is accessing it
     }

Javascript解决方案也很受欢迎

假设有一个表可以跟踪用户访问页面的情况。

表访问

userid pageid current_access
  1      1      Yes
  1      2      No
  2      2      No
  3      3      No

Now check that if the user is accessing the page or not. If it returns yes then disable submit button otherwise keep it enable.

查询:

$sql = "SELECT * FROM table_access WHERE userid = 1 AND pageid = 1 AND current_access = 'Yes'";

如果以上查询返回的记录>0,则禁用提交按钮。

编辑:

每当用户登录table_access页面时更新该页面。