一個(gè)簡單的網(wǎng)頁密碼登陸php代碼
更新時(shí)間: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)文章
Laravel框架實(shí)現(xiàn)定時(shí)Task Scheduling例子
今天小編就為大家分享一篇Laravel框架實(shí)現(xiàn)定時(shí)Task Scheduling例子,具有很好的參考價(jià)值,希望對大家有所幫助。一起跟隨小編過來看看吧2019-10-10PHP抓取、分析國內(nèi)視頻網(wǎng)站的視頻信息工具類
VideoUrlParser是一款基于PHP根據(jù)視頻URL抓取視頻信息的工具,支持優(yōu)酷、土豆、酷六、56、樂視、搜狐、騰訊、新浪。2014-04-04Joomla數(shù)據(jù)庫操作之JFactory::getDBO用法
這篇文章主要介紹了Joomla數(shù)據(jù)庫操作之JFactory::getDBO用法,實(shí)例分析了Joomla靜態(tài)類JFactory使用getDBO取得數(shù)據(jù)庫對象的相關(guān)操作技巧,需要的朋友可以參考下2016-05-05php 判斷過去離現(xiàn)在幾年的函數(shù)(實(shí)例代碼)
下面小編就為大家?guī)硪黄猵hp 判斷過去離現(xiàn)在幾年的函數(shù)(實(shí)例代碼)。小編覺得挺不錯的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧2016-11-11PHP獲取input輸入框中的值去數(shù)據(jù)庫比較顯示出來
這篇文章主要介紹了PHP獲取input輸入框中的值去數(shù)據(jù)庫比較顯示出來的相關(guān)資料,前端還算比較簡單,php后臺接受并查詢,本文給大家介紹的非常詳細(xì),具有參考借鑒價(jià)值,需要的朋友可以參考下2016-11-11