[英]How to make html table cell information accessible to only the user that entered the information
I am trying to make an appointment calendar and I am using html table for to do this. 我正在尝试创建约会日历,并且正在使用html表来执行此操作。 I want a situation where if a user clicks an empty cell (time slots eg 8:00 or 8:15 are divided into cells using ), a form pops up and the user fills the form. 我想要一种情况,如果用户单击一个空单元格(使用,将8:00或8:15等时隙划分为多个单元格),则会弹出一个表格,用户会填写表格。 After the user fills the form, the form data is saved into a database. 用户填写表单后,表单数据将保存到数据库中。 But if a cell slot has already been filled by a particular user, the data of that slot should be accessible to that user and greyed out to other users. 但是,如果某个特定用户已经填充了一个单元槽,则该用户应可以访问该槽的数据,而其他用户则应将该数据显示为灰色。 If the cell is empty, it should make the cell clickable to everyone. 如果该单元格为空,则应使该单元格对所有人都可单击。 But if the cell is not empty, that is, a user already booked an appointment in that cell, it should allow the cell to be clickable by only the user and admin and should not be clickable to other users. 但是,如果该单元格不为空,也就是说,用户已经在该单元格中预订了约会,则应允许该单元格只能由该用户和管理员单击,而其他用户则不能单击。 And also the user should be able to edit the content of the cell. 用户也应该能够编辑单元格的内容。
How do I go about this? 我该怎么办? I am using PHP and JavaScript. 我正在使用PHP和JavaScript。
Below is what I have done so far. 以下是我到目前为止所做的事情。
if($_SESSION['interval'] == 30)
{
echo "<td onclick=popUpForm('$hoursDisplay[$x]:00-$hoursDisplay[$x]:30','$date')> </td><td onclick=popUpForm('$hoursDisplay[$x]:30-".$hoursDisplay[$x+1].":00','$date')> </td>";
}
if($_SESSION['interval'] == 20)
{
echo "<td onclick=popUpForm('$hoursDisplay[$x]:00-$hoursDisplay[$x]:20','$date')> </td><td onclick=popUpForm('$hoursDisplay[$x]:20-$hoursDisplay[$x]:40','$date')> </td><td onclick=popUpForm('$hoursDisplay[$x]:40-".$hoursDisplay[$x+1].":00','$date')> </td>";
}
if($_SESSION['interval'] == 15)
{
echo "<td onclick=popUpForm('$hoursDisplay[$x]:00-$hoursDisplay[$x]:15','$date')> </td><td onclick=popUpForm('$hoursDisplay[$x]:15-$hoursDisplay[$x]:30','$date')> </td><td onclick=popUpForm('$hoursDisplay[$x]:30-$hoursDisplay[$x]:45','$date')> </td><td onclick=popUpForm('$hoursDisplay[$x]:45-".$hoursDisplay[$x+1].":00','$date')> </td>";
}
Once the user logs in, set a cookie. 用户登录后,设置一个cookie。 When a request comes for an empty cell serve the form, otherwise check the cookie to authenticate the user. 当请求输入空单元格时,请为该表单提供服务,否则请检查Cookie以验证用户身份。 If the cookie doesn't match then give an error. 如果Cookie不匹配,请输入错误。 Login authentication is covered here 登录身份验证在这里介绍
As user has to be logged in to be identified you should simply serve the good html cell code regarding the user state. 由于必须登录才能识别用户,因此您只需提供有关用户状态的良好html单元格代码即可。 Lets imagine you have a session with thoose datas: 假设您正在使用thoose数据进行会话:
$_SESSION = array('userId'=>1,'isAdmin'=>false);
then checking if you have appointment or not, and if the user is owner of the appointment or admin you can know easily wich version of the cell you have to render (clickable or not). 然后检查您是否有约会,并且如果用户是约会或管理员的所有者,您可以轻松知道必须渲染的单元格的版本(可单击或不单击)。
There's no need to make a particular use of javascript here as all datas are available server side at render time i imagine. 我想不需要在这里特别使用javascript,因为所有数据都可以在渲染时从服务器端获取。
Your question is too vague and should be precised a bit if you want us to respond more precisely on a point. 您的问题太含糊,如果您想让我们在某一点上做出更准确的答复,则应该稍微澄清一点。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.