如何在php或html中保护会员资格安全的个人资料页面? [英] How do I secure a profile page for membership saftey in php or html?

查看:48
本文介绍了如何在php或html中保护会员资格安全的个人资料页面?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我需要保护个人资料页面[这是链接]任何人都可以访问它,我不希望发生这种情况我希望该页面保持关闭/或锁定,直到有人登录。我的网站有会员资格,我希望保护会员免受登录的人员的侵害,或者他们可以在不付费的情况下使用会员资格。

这是我的代码profile.php:



 <?php  
< span class =code-comment> // 检查用户是否登录
if($ user_logged_in == true )
{
require ' profile_loggedin.php';
}
else
{
require ' < span class =code-string> profile_notloggedin.php';
}
?>





< pre lang =text>这是user_notloggedin.php的代码



 < ?php  
include(' cn.php');
?>



 <  !DOCTYPE     html     PUBLICK     -  // W3C // DTD     XHTML  < span class =code-attribute>   1.0     Transitional // EN   http://www.w3.org/TR/xhtml1/ DTD / xhtml1-transitional.dtd >  
< html xmlns = http://www.w3.org/1999/xhtml >
< head >
< title > 登录< / title >
< / head >
< body >
< 表格 action = 轮廓。 php 方法 = 发布 >
< p > 用户名:< / p >
< 输入 type = text name = userUsername col = 50 / >
< p > 密码: < / p >
< 输入 类型 = 密码 name = userPassword col = 50 / >
< br < span class =code-attribute> / >
< input 类型 = 提交 value = login / >
< br / > < br / >
< a href = register.php > 注册< / a >
< / form >
< a href = http://lulzhost.net76.net/advlogin/contact/index.html > 或者转到此处通用电器有效的帐户< / a >
< a href = http://lulzhost.net76。 net / mm / > < h3 > 不希望帐户访问此处观看我们拥有的视频或发布视频< / h3 > < / a >
< / body >
< / html >

解决方案

user_logged_in == true)
{
require ' profile_loggedin.php';
}
else
{
require ' < span class =code-string> profile_notloggedin.php';
}
?>





< pre lang =text>这是user_notloggedin.php的代码



 < ?php  
include(' cn.php');
?>



 <  !DOCTYPE     html     PUBLICK     -  // W3C // DTD     XHTML  < span class =code-attribute>   1.0     Transitional // EN   http://www.w3.org/TR/xhtml1/ DTD / xhtml1-transitional.dtd >  
< html xmlns = http://www.w3.org/1999/xhtml >
< head >
< title > 登录< / title >
< / head >
< body >
< 表格 action = 轮廓。 php 方法 = 发布 >
< p > 用户名:< / p >
< 输入 type = text name = userUsername col = 50 / >
< p > 密码: < / p >
< 输入 类型 = 密码 name = userPassword col = 50 / >
< br < span class =code-attribute> / >
< input 类型 = 提交 value = login / >
< br / > < br / >
< a href = register.php > 注册< / a >
< / form >
< a href = http://lulzhost.net76.net/advlogin/contact/index.html > 或者转到此处通用电器有效的帐户< / a >
< a href = http://lulzhost.net76。 net / mm / > < h3 > 不希望帐户访问此处观看我们拥有的视频或发布视频< / h3 > < / a >
< / body >
< / html >


这很简单。您只需要检查用户是否登录的天气。如果登录则渲染页面,如果不是,则不渲染页面。



 <?  php   

// profile.php



//您 check 如果 user 已记录

if(


user_logged_in = = true)

{

< span class =code-summarycommen t>>
<! - 用户已登录。渲染安全页面! - >
< p > 欢迎您,您已登录安全页面< / p >
<? php

}

else

{

>
<! - 用户未登录。打印错误消息! - >
< p > ; 请登录以继续< / p >
<? php

}

>





技巧:更好的方法是你可以创建3个文件。

- profile.php

- profile_loggedin.php

- profile_not_loggedin.php



然后,



 < ?php 
// 检查用户是否已登录
if


So I need to secure a profile page [Here is the link] Well anyone can access it and I don't want that to happen I want that page to stay closed/or locked until someone has logged on. My website has memberships and I want to protect the memberships from people logging in to it or they will be able to use the membership without paying.

Here is my code for profile.php:


<?php
//You check if the user is logged in or not
if($user_logged_in == true)
{
    require 'profile_loggedin.php';
}
else
{
    require 'profile_notloggedin.php';
}
?>



Here is the code for user_notloggedin.php


<?php
include('cn.php');
?>


<!DOCTYPE html PUBLICK "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Login</title>
</head>
<body>
<form action="profile.php" method="post">
	<p>Username:</p>
	<input type="text" name="userUsername" col="50" />
	<p>Password:</p>
	<input type="password" name="userPassword" col="50" />
	<br />
	<input type="submit" value="login" />
	<br /><br />
	<a href="register.php">Register</a>
</form>
<a href="http://lulzhost.net76.net/advlogin/contact/index.html">Or go here to get a account that works</a>
<a href="http://lulzhost.net76.net/mm/"><h3>Don't want an account go here to watch some of the vids we have or post a vid</h3></a>
</body>
</html>

解决方案

user_logged_in == true) { require 'profile_loggedin.php'; } else { require 'profile_notloggedin.php'; } ?>



Here is the code for user_notloggedin.php


<?php
include('cn.php');
?>


<!DOCTYPE html PUBLICK "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Login</title>
</head>
<body>
<form action="profile.php" method="post">
	<p>Username:</p>
	<input type="text" name="userUsername" col="50" />
	<p>Password:</p>
	<input type="password" name="userPassword" col="50" />
	<br />
	<input type="submit" value="login" />
	<br /><br />
	<a href="register.php">Register</a>
</form>
<a href="http://lulzhost.net76.net/advlogin/contact/index.html">Or go here to get a account that works</a>
<a href="http://lulzhost.net76.net/mm/"><h3>Don't want an account go here to watch some of the vids we have or post a vid</h3></a>
</body>
</html>


It's very simple. You just have to check weather the user is logged in or not. If logged in you render the page, if not you do not render the page.

<?php

//profile.php



//You check if the user is logged in or not

if(


user_logged_in == true) { ?> <!--User is logged in. Render your secure page!--> <p>Welcome, You're logged in to a secure page</p> <?php } else { ?> <!--User is not logged in. Print an error message!--> <p>Please log in to continue</p> <?php } ?>



A Technique: A better way is you can create 3 files.
-- profile.php
-- profile_loggedin.php
-- profile_not_loggedin.php

Then,

<?php
//You check if the user is logged in or not
if(


这篇关于如何在php或html中保护会员资格安全的个人资料页面?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆