PHP小程序-帐号登陆验证

通过清心醉

PHP小程序-帐号登陆验证

//首先是index.php

<?php
require_once(“judge.php”);
//把帐户验证包含进来.
//通过以上的OK.php文件,把接受到的参数传递过去判断.
?>
<html>
<title>管理</title>
<frameset rows=”66,*” cols=”*” frameborder=”no” border=”0″ framespacing=”0″>
<frame src=”top.php” name=”topFrame” scrolling=”No” noresize=”noresize” title=”topFrame” />
<frameset rows=”*” cols=”210,*” framespacing=”0″ frameborder=”no” border=”0″>
<frame src=”left.php” name=”leftFrame” title=”leftFrame” />
<frame src=”main.php” name=”mainFrame” title=”mainFrame” />
</frameset>
</frameset>
<noframes><body>
</body></noframes>
</html>

 

//接下来是判断文件OK.php

<?php
//身份验证文件
$username=”admin”;
$userpassword=”admin888″;
ini_set(“display_errors”,1); //显示错误
header(“Cache-Control: no-cache, must-revalidate”); //禁止缓存
header(“Pragma: no-cache”); //禁止缓存
date_default_timezone_set(“PRC”); //时差
session_start();
if((isset($_POST[“user”]) && !empty($_POST[“user”]) && $username==$_POST[“user”])&&(isset($_POST[“password”]) && !empty($_POST[“password”]) && $userpassword==$_POST[“password”]))
{
$_SESSION[“user”]=$_POST[“user”];
$_SESSION[“password”]=$_POST[“password”];
}
else
{
header(“location:login.php”);
exit;
//因为index.php包含了这文件,所以$_SESSION没有用户资料的时候直接跳转到login.php
}
?>

//然后是login.php

<html>
<title>管理员登陆</title>
<body>
<form method=”post” action=”index.php”>
<table width=”400″ align=”center”>
<tr>
<td>管理员帐号:</td>
<td><input name=”user” type=”user” size=”30″ maxlength=”500″></td>
</tr>
<tr>
<td>管理员密码:</td>
<td><input name=”password” type=”password” size=”30″ maxlength=”500″></td>
</tr>
</table>
<div align=”center”><input type=”submit” value=”登陆”></div>
<?php
//用户输入之后,返回到index.php
?>
</form>
</body>
</html>

&amp;lt;br /&amp;gt;

关于作者

清心醉 administrator

发表评论

如果喜欢作者的文章,您可以打赏给作者:

TRC20(虚拟货币):


ERC20(虚拟货币):


Bitcoin(BTC):