PHP+MYSQL+MYSQL+SESSION实现用户登录的实例
这是我写的用户登录界面。
<?php //系统登陆界面
session_start();
include("menu2.php");
require("configywcl.php");//加载配置文件
require("functions.php");
?>
<html>
<head><title>请登录系统</title></head>
<?php
if ($username)
{
$password=md5($password);
$sql="select * from user where username="$username" and password="$password"";
$result=mysql_query($sql);
$num_rows=mysql_num_rows($result);
if ($num_rows==1)
{
//如果用户名和密码与数据库中的信息匹配则赋值赋权限,并定向index.php
$row=mysql_fetch_assoc($result);
$_SESSION["ywclusername"]=$row["username"];
$_SESSION["ywclrealname"]=$row["realname"];
$realnamelog=$row["realname"];
$_SESSION["ywclkeshi"]=$row["keshi"];
$_SESSION["ywcljibie"]=$row["jibie"];
// 往系统日志中写入信息
$iplog=$_SERVER["REMOTE_ADDR"];
//echo $iipp;
$sqllog="insert into log (username,realname,intime,iplog,action) values("$username","$realnamelog",now(),"$iplog","登录")";
$resultlog=mysql_query($sqllog);
header("location:index.php");
}
else {
die("<h2 align="center"><font color="red">用户名或者密码错误!</font>请<a href="login.php">返回</a>。</h2>");
}
}
?>
<form method="post" action="login.php">
<!--登陆的界面-->
<p> </p>
<table width="100%" class="touming" border="0">
<tr class="wubian">
<td class="wubian" colspan="2" align="center" valign="middle"><span class="style3">用 户 登 录</span></td>
</tr>
<tr class="wubian">
<td class="wubian" width="40%" align="right" valign="middle"><div align="right"><span class="style1"><img src="images/user.png" class="t3"></span></div></td>
<td class="wubian" width="60%"><span class="style1">用 户:</span> <input name="username" type="text" size="20" autofocus></td>
</tr>
<tr class="wubian">
<td class="wubian" align="right" valign="middle"><div align="right"><span class="style1"><img src="images/password.png" class="t3"></span></div></td>
<td class="wubian" width="62%"><span class="style1">密 码:</span> <input name="password" type="password" size="20"></td>
</tr>
<tr class="wubian">
<td class="wubian"colspan="2" align="center" valign="middle"><iframe src="http://m.weather.com.cn/m/pn11/weather.htm?id=101011200T " width="490" height="50" marginwidth="0" marginheight="0" hspace="0" vspace="0" frameborder="0" scrolling="no"></iframe></td>
</tr>
</table>
<div align="center">
<input type="submit",name="submit" value="登录" class="button">
</div>
</form>
<?php
include("foot.php");
?>
</html>
声明:该文观点仅代表作者本人,入门客AI创业平台信息发布平台仅提供信息存储空间服务,如有疑问请联系rumenke@qq.com。
- 上一篇:没有了
- 下一篇: PHP+MYSQL+JQUERY实现内容的筛选或实时搜索
