发布于 2014-12-21 15:16:06 | 164 次阅读 | 评论: 0 | 来源: 网友投递

这里有新鲜出炉的PHP设计模式,程序狗速度看过来!

PHP开源脚本语言

PHP(外文名: Hypertext Preprocessor,中文名:“超文本预处理器”)是一种通用开源脚本语言。语法吸收了C语言、Java和Perl的特点,入门门槛较低,易于学习,使用广泛,主要适用于Web开发领域。PHP的文件后缀名为php。


本文是一个php实现的一个简单的网页密码登陆示例,感兴趣的同学参考下.


<?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 = "请输入密码查看,获取密码可联系我。";
}
}
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>phperz提醒你输入密码</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>


最新网友评论  共有(0)条评论 发布评论 返回顶部

Copyright © 2007-2017 PHPERZ.COM All Rights Reserved   冀ICP备14009818号  版权声明  广告服务