【php开源代码栏目提醒】:网学会员,鉴于大家对php开源代码十分关注,论文会员在此为大家搜集整理了“login_face.php”一文,供大家参考学习!
<?php
// 初始化session
session_start();
// 包含数据库连接文件
require ('dbconnect.php');
if(isset($_SESSION['UserName'])) {
//重定向到members.php,以便在左上框架中显示在线用户
header("Location:members.php");
// 登录过的话,立即结束
exit;
}
?>
<html>
<script language="javascript">
function checklogin()
{
if ((login.username.value!="") && (login.password.value!=""))
// 如果昵称和密码均不为空,则返回true
return true
else {
// 如果昵称或密码为空,则显示警告信息
alert("昵称或密码不能为空!")
return false
}
}
</script>
<body>
<form action="login.php" method="post" name="login" onsubmit="return checklogin()">
<p align="center">请登录:</p>
<table align="center" border="0">
<tr>
<th>
昵称:
</th>
<th>
<input type="text" size=10 name="username">
</th>
</tr>
<tr>
<th>
密码:
</th>
<th>
<input type="pass
word" size=10 name="password">
</th>
</tr>
<tr>
<th colspan="2" align="right">
<input type="submit" value="登录">
<br>
<a href="register.php">
注册?</a>
</form>
</th>
</tr>
</table>
</body>
</html>