很多站长朋友们都不太清楚PHP网页提示代码,今天小编就来给大家整理PHP网页提示代码,希望对各位有所帮助,具体内容如下:
本文目录一览: 1、 PHP网页如果需要查看信息必须输入密码,验证后才可显示出内容的代码如何实现? 2、 在PHP页面中怎样添加弹出广告代码是什么?? 3、 如何解决Linux环境下访问PHP页面时,页面上显示数据库代码的问题 4、 php在网页上显示代码 5、 求助:php,打开网页显示的都是代码 PHP网页如果需要查看信息必须输入密码,验证后才可显示出内容的代码如何实现?相关代码如下:
新建一个PHP文件如下:
<?php??
header('Content-type:text/html;charset=utf-8');
$password?=?"1234";?//?这里是正确密码??
$p?=?"";??
if(isset($_COOKIE["isview"])??$_COOKIE["isview"]?==?$password){??
$isview?=?true;??
}else{??
if(isset($_POST["pwd"])){??
if($_POST["pwd"]?==?$password){??
setcookie("isview",$_POST["pwd"],time()+3600*0.2);??
$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"?"?">?
<html?xmlns="?">?
<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=""?method="post"?style="margin:0px;">输入查看密码??
<input?type="password"?name="pwd"?/>?<input?type="submit"?value="查看"?/>??
</form>??
<?php?echo?$p;??>??
</div>??
</div>??
</body>??
</html>?
<?php??
}??>
在PHP页面中怎样添加弹出广告代码是什么??PHP网页打开自动弹出广告,五秒后自动关闭的网页代码如下:
新建网页写入代码即可
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
<html xmlns="">
<head>
<title>网页弹出广告窗口 boaer测试数据</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css">
body,html{margin:0;padding:0;font-size:12px;font-family:Arial;font:12px/1 Helvetica, Tahoma, Arial, \5b8b\4f53, sans-serif;}
.fixedMask{position:fixed; display:none;top:0; left:0; z-index:999; width:100%; height:100%; background:#000; filter:alpha(opacity=30); opacity:0.3; }
* html { background:url(*) fixed; }
* html body { margin:0; height:100%; }
* html .fixedMask{ position: absolute; left: expression(documentElement.scrollLeft + documentElement.clientWidth - this.offsetWidth); top: expression(documentElement.scrollTop + documentElement.clientHeight - this.offsetHeight); }
#ad{width:570px;height:345px;border:1px solid #333;border-top-width:5px;position:absolute;z-index:9999;left:50%;margin-left:-290px;top:50%;margin-top:-175px;display:none;}
#ad a{display:block;position:absolute;text-decoration:none;right:0;top:0px;font: 12px/1.5 arial;background:#B50000;padding:2px 5px;color:#fff;}
#ad a:hover{background:red;}
</style>
</head>
<body>
<iframe scrolling="no" src="" style="width:100%;height:1000px"></iframe>
<div id="ad">
<a href="#1" >关闭</a>
<img src="" alt="" />
</div>
</body>
<script type="text/javascript">
//<![CDATA[
alert('5秒后自动关掉!');
function Mask() {
if (Mask.instance) return Mask.instance;
this.el = document.body.appendChild(document.createElement('DIV'));
this.el.className = 'fixedMask';
Mask.instance = this;
};
Mask.prototype = {
show: function(fn) {
this.el.style.display = 'block';
fnfn();
},
hide: function(fn) {
this.el.style.display = 'none';
fnfn()
}
};
var x=new Mask();
var AD=document.getElementById('ad');
AD.getElementsByTagName('A')[0].onclick=hide;
x.show(function (){
AD.style.display='block';
});
setTimeout(hide,5000);
function hide(){
x.hide(function (){
AD.style.display='none';
})
}
//]]>
</script>
</html>
如何解决Linux环境下访问PHP页面时,页面上显示数据库代码的问题出现此问题的原因是由于在.htaccess文件中添加了下面两行:
AddHandler application/x-httpd-php53 .php
AddHandler application/x-httpd-php54 .php
在这些行的开始位置插入#注释掉之后就可以正常使用了。
php在网页上显示代码<?php
$name?=?isset($_POST["name"])???$_POST["name"]?:?"";
$password?=?isset($_POST["password"])???$_POST["password"]?:?"";
$conn?=?@mysql_connect("localhost","root","123")or?die("connection?failed!");
mysql_select_db("web");
mysql_query("set?names?utf8");
if($name?==?""?||?$password?==?"")
{
????echo?"<script>alert('login-failed!')</script>";
????exit;
}
else
{
????$query?=?mysql_query("select?password?from?user?where?name=".$name);
????$row?=?mysql_fetch_array($query);
????if($row[0]?==?$password)
????{
????????echo?"<script>alert('login-success!')</script>";
????}
}
?>
求助:php,打开网页显示的都是代码你没有PHP环境,打开页面当然都是代码。去安装一个phpstudy,设置好虚拟服务器访问路径,然后把文件放进去,直接通过浏览器访问localhost就可以看你的代码有没有问题了!
关于PHP网页提示代码的介绍到此就结束了,不知道本篇文章是否对您有帮助呢?如果你还想了解更多此类信息,记得收藏关注本站,我们会不定期更新哦。
查看更多关于PHP网页提示代码 php网页显示乱码的详细内容...