[英]How to allow only registered users to have access to their information in mysql database?
I am setting up a student portal for a basci school.我正在为 basci 学校建立一个学生门户。 In the portal, students should be able to access their grades, courses, course materials, messages from their tutors and also view their payment details and how much they owe the school.在门户中,学生应该能够访问他们的成绩、课程、课程材料、来自导师的消息,还可以查看他们的付款详细信息以及他们欠学校的金额。
I have mysql tables ( 8 tables in all) with various relationships that is linked to their STUDENT ID.我有 mysql 表(总共 8 个表),其中包含链接到学生 ID 的各种关系。
I want each student to be able to login using username and password - I have the script already with a users table that stores the username and password credentials.我希望每个学生都能够使用用户名和密码登录 - 我已经有一个带有用户表的脚本,用于存储用户名和密码凭据。
Here are my questions:以下是我的问题:
Points to note:注意事项:
The ONLY problem is how to query the relational tables such that each registered user only sees his or her information only.唯一的问题是如何查询关系表,使每个注册用户只能看到他或她的信息。 Information is viewed based on the user.信息是基于用户查看的。
If anyone can point me in the right direction, it would be appreciated.如果有人能指出我正确的方向,将不胜感激。 Thank you.谢谢你。
Firstly you dont ask such questions so you wont get down voted and blocked now let me help feel free to contact me and upvote please i am new too and read more on querying database you might not be this lucky next time首先,你不会问这样的问题,所以你不会被投票和阻止,现在让我帮助随时联系我并投票,请我也是新人,阅读更多关于查询数据库的信息,下次你可能不会这么幸运
//lets say showstudentsrecordpage.php after they are logged in, you use a cookie a session up to you get their auto incremented ids from database when they log in and query any table you want to with that id
//create a table so you can show that user info after query
<table>
<th>sTUDENT NAME</th>
<th>sTUDENT rrecord</th>
<th>sTUDENT subject</th>
// showstudentsrecordpage.php
$studentcookieafterloggedin = $_COOKIE['userid']; //userid of student who logged in successfully
$studentcookieafterloggedin = mysqli_escape_string($con, $studentcookieafterloggedin);
$bringtheirrecordout = "SELECT FROM mayberecordstable WHERE id= '$studentcookieafterloggedin'";
$runthequery = mysqli_query($con, $bringtheirrecordout);
//variable $con is your connection parameters
if (mysqli_num_rows($runthequery) < 1){
Do what you want here if that user id is not found probably a redirect or something anything you want
}
//you dont need a while loop since it is only one record for a student if it is multiple records for different students then while loop is needed
$fetcharray = mysqli_fetch_array($runthequery);
//this are my own parameters just change it to your own database values
$id = $fetcharray['id'];
$studentname = $fetcharray['studentname'];
$studentgrades = $fetcharray['studentgrades'];
$subjects = $fetcharray['subjects'];'
then show it
<div>
//continue your table for it here
<tr>
<td><?php echo $studentname ?></td>
<td><?php echo $studentgrades ?></td>
<td><?php echo $subjects ?></td>
</tr>
</table>
</div>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.