# 帝国CMS正文内容如何实现输入密码查看全文

*Published:* 2024-08-05
*Author:* 客服001

#### 温馨提醒

如果文章内容或图片资源失效，请留言反馈，我们会及时处理，谢谢

本文最后更新于2024年8月5日，已超过 180天没有更新



可用来实现密码查看收费内容或者用来微信引流!每个信息可以单独设置密码，如果设置密码就提示输入密码才能查看新闻正文，如果没设置密码就不提示输入密码，直接显示新闻正文内容!自动判断!

**操作过程：**

1.在系统模型新建一个mima的字段

2.在内容页对应位置添加如下代码：

```
<!--密码-->
<?php
if(!$navinfor[mima])
{
?>
你需要输入密码

<?
}else{
?>

<?php
if(isset($_POST['password'])){
   $pwd=$_POST['password'];
   if($pwd == $navinfor[mima]){
?>

[!--newstext--]
<?  
   }else{
   echo "<script>alert('密码错误');</script>";
   }
}
?>

<?
  if($pwd !== $navinfor[mima]){
  ?>


<div class="zz_pic2">
   <div class="houhao_top">
    <span>此处内容仅供会员查看，请输入验证码后查看本文隐藏内容</span>
     <img src="/skin/jxhx/images/wx.png" />
    <div class="houhao_search">
    <form action="/e/action/ShowInfo.php?classid=[!--classid--]&id=[!--id--]" method="post">
     请输入验证码后继续：<input type="password" name="password" placeholder="请在这里输入验证码" class="houhao_bar" />
     <input type="submit" value="确认" class="houhaoresults" />
     </form>

     
    </div>
    <div class="kouhaohuoqu1">
            <div class="kouhaohuoqu">
    方式1：微信扫码，发送66免费获得验证码
   </div>
   <div class="timezen">
    方式2：猜一猜万一猜对了呢
   </div>
   <div class="timezen">
    方式3:花几秒时间注册个会员免费查看
   </div>
   </div>
   </div>
  


  </div>
<div class="clear"></div>
<?
}
?>


<?
}
?>
<!--密码-->
```

3.这是最重要的一点，一定要保证这个页面是动态页面。如果不这样做的话，是没法达到想要的效果的。因为这个代码执行是动态判断的。静态页面根本就实现不了。

**动态页面设置教程**

如果你开启了动态页面以后，那就需要设置伪静态。

这里拿宝塔举例：(设置完伪静态一定要记得重启Apache)

[![](https://www.xarjtc.com/wp-content/uploads/2024/08/353515f16382ccc.webp)](https://www.xarjtc.com/wp-content/uploads/2024/08/353515f16382ccc.webp)

代码如下：

```
RewriteEngine On
ErrorDocument 404 /404.html
Rewritebase /
#信息列表
RewriteCond %{QUERY_STRING} ^(.*)$
RewriteRule ^listinfo-(.+?)-(.+?).html$ /e/action/ListInfo/index.php?classid=$1&page=$2
#信息内容页
RewriteCond %{QUERY_STRING} ^(.*)$
RewriteRule ^showinfo-(.+?)-(.+?)-(.+?).html$ /e/action/ShowInfo.php?classid=$1&id=$2&page=$3
#标题分类列表页
RewriteCond %{QUERY_STRING} ^(.*)$
RewriteRule ^infotype-(.+?)-(.+?).html$ /e/action/InfoType/index.php?ttid=$1&page=$2
#TAGS信息列表页
RewriteCond %{QUERY_STRING} ^(.*)$
RewriteRule ^tags-(.+?)-(.+?).html$ /e/tags/index.php?tagname=$1&page=$2
#评论列表页
RewriteCond %{QUERY_STRING} ^(.*)$
RewriteRule ^comment-(.+?)-(.+?)-(.+?)-(.+?)-(.+?)-(.+?).html$  /e/pl/index.php?doaction=$1&classid=$2&id=$3&page=$4&myorder=$5&tempid=$6
```

然后在帝国后台设置好伪静态就行了，这里直接点击默认就行。

注：(如果你有能力可以改一下伪静态规则，服务器和后台一定要对应好，不然容易出现发布文章打不开的情况，自己写伪静态规则必须要带有classid,id,page,如果不想带，那只能是二开了)。