简体   繁体   English

如何防止非注册用户加载注册用户的网页?

[英]How to prevent non registered users to load web pages for registered users?

I'm building a website for didactic purpose. 我正在建立一个用于教学目的的网站。 I have some .htm page accessible from all user and other pages accessible only for registered user with a database (username and passowrd). 我有一些.htm页面可供所有用户访问,而其他页面仅适用于具有数据库的注册用户(用户名和passowrd)。

My professor wants that I don't generate web pages with php, but I must have the .htm files for web pages. 我的教授希望我不要使用php生成网页,但是我必须拥有用于网页的.htm文件。

For example for homepage I have "homepage.htm" and "hompage_logged.htm". 例如对于主页,我有“ homepage.htm”和“ hompage_logged.htm”。

How can I prevent an unregistred user lo load a page for registered user if he knows the URL? 如果未注册用户知道URL,如何防止未注册用户加载页面?

You will need to create session variables for the user once they are logged in. Once you have done that you will add a php script similar to this, 登录用户后,您需要为其创建会话变量。完成后,您将添加与此类似的php脚本,

<?php
session_start();
if(isset($_SESSION['username'])){
   echo "<html> Your html here </html>";
}
?>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM