一個簡單的網(wǎng)頁密碼登陸php代碼
更新時間:2012年07月17日 10:33:10 作者:
密碼對,就可以看到指定內(nèi)容, 密碼不對就進(jìn)不去
復(fù)制代碼 代碼如下:
<?php
$password = "1234"; // 這里是密碼
$p = "";
if(isset($_COOKIE["isview"]) and $_COOKIE["isview"] == $password){
$isview = true;
}else{
if(isset($_POST["pwd"])){
if($_POST["pwd"] == $password){
setcookie("isview",$_POST["pwd"],time()+3600*3);
$isview = true;
}else{
$p = (empty($_POST["pwd"])) ? "需要密碼才能查看,請輸入密碼。" : "密碼不正確,請重新輸入。";
}
}else{
$isview = false;
$p = "請輸入密碼查看,獲取密碼可聯(lián)系我。";
}
}
if($isview){ ?>
這里是密碼成功后顯示的地方
<?php }else{ ?>
<!DOCTYPE html PUBLIC "-//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>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="pragma" content="no-cache" />
<meta http-equiv="cache-control" content="no-cache" />
<meta http-equiv="expires" content="0" />
<title>腳本之家提醒你輸入密碼</title>
<!--[if lt IE 6]>
<style type="text/css">
.z3_ie_fix{
float:left;
}
</style>
<![endif]-->
<style type="text/css">
<!--
body{
background:none;
}
.passport{
border:1px solid red;
background-color:#FFFFCC;
width:400px;
height:100px;
position:absolute;
left:49.9%;
top:49.9%;
margin-left:-200px;
margin-top:-55px;
font-size:14px;
text-align:center;
line-height:30px;
color:#746A6A;
}
-->
</style>
<div class="passport">
<div style="padding-top:20px;">
<form action="?yes" method="post" style="margin:0px;">輸入查看密碼
<input type="password" name="pwd" /> <input type="submit" value="查看" />
</form>
<?php echo $p; ?>
</div>
</div>
<?php
} ?>
</body>
</html>
相關(guān)文章
thinkPHP5框架設(shè)置404、403等http狀態(tài)頁面的方法
這篇文章主要介紹了thinkPHP5框架設(shè)置404、403等http狀態(tài)頁面的方法,結(jié)合實例形式分析了thinkPHP5框架設(shè)置404頁面的相關(guān)配置、視圖顯示頁面及控制器調(diào)用相關(guān)操作技巧,需要的朋友可以參考下2018-06-06
網(wǎng)頁的分頁下標(biāo)生成代碼(PHP后端方法)
網(wǎng)頁的分頁選擇效果直接影響用戶的使用體驗。類似功能的方法有很多,我在這里寫的方法主要是的優(yōu)勢在于前后端分離,可以自己定義長度和分頁的行數(shù)2016-02-02
PHP下使用mysqli的函數(shù)連接mysql出現(xiàn)warning: mysqli::real_connect(): (hy
這篇文章主要介紹了PHP下使用mysqli的函數(shù)連接mysql出現(xiàn)warning: mysqli::real_connect(): (hy000/1040): ...的相關(guān)資料,需要的朋友可以參考下2016-02-02
Laravel 驗證碼認(rèn)證學(xué)習(xí)記錄小結(jié)
這篇文章主要介紹了Laravel 驗證碼認(rèn)證學(xué)習(xí)記錄小結(jié),文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2019-12-12
PHP經(jīng)典面試題之設(shè)計模式(經(jīng)常遇到)
php中設(shè)計模式非常多,但是設(shè)計模式在php面試題經(jīng)常會提到,本文主要給大家介紹php經(jīng)典面試題之設(shè)計模式,需要的朋友一起看看吧2015-10-10

