/*

包括的文件

*/

/*

login.php

*/

<?php
require('./mysql.php');
$username=$_REQUEST['username'];
$passwd=$_REQUEST['passwd']
session_start();
$_SESSION['s_username']=$username;
$query_user="select * from user where username = '$username' and passwd = '$passwd'";
$db=new mysql();//实例化类mysql
$result = $db->query_exec($query_user);//验证用户
$num_results=$result->num_rows;//取得数据库中的记录行

if($num_results==0)
{
    echo 'login fail!!';
?>
<p><a href="./template/login.htm">返回登陆</a></p>
<?php
}else{
header("Location: ./index.php");
}
?>

/*

templates/login.tpl

*/

<html>
<head>
<meta http-equiv="text/html;charset='utf-8'">
<link  rel="stylesheet" type="text/css" href="./css/login.css">
<script type="text/javascript" src="js/face.js"></script>
</head>
<body>
<table width="400px" height="208" border="0" cellpadding="0" cellspacing="0" >
<form id="login" name="login" method="post" action="a.php" onSubmit="">
  <tr>
    <td height="25"  align="right">用户名:</td>
    <td><input name="name" type="text" onmouseover="this.style.backgroundColor='#ffffff'" onMouseOut="this.style.backgroundColor='#e8f4ff'" size="15" /></td>
  </tr>
  <tr>
    <td height="25" align="right">密码:</td>
    <td><input name="password" type="password" id="password"  onmouseover="this.style.backgroundColor='#ffffff'" onMouseOut="this.style.backgroundColor='#e8f4ff'" size="15" /></td>
  </tr>
  <tr>
    <td height="25"align="right">验证码:</td>
    <td><input name="check" type="text" id="check"  onmouseover="this.style.backgroundColor='#ffffff'" onMouseOut="this.style.backgroundColor='#e8f4ff'" size="10" /><img src="code.php" id="code" /></td>
  </tr>

/*

mysql.php

*/

<?php
    var $db_host    = 'localhost';
    var $db_username= 'root';
    var $db_password= '123';
    var $db_database= 'new';

$db =mysql_connect($ db_host,$db_username,$-> db_password,$-> db_database);
        if (mysqli_connect_errno()) {
            echo "连接数据库失败!";
            exit;
        }
        return $db;
    }
    
}
?>

/*

效果为*/

 
分类: PHP

最新文章

  1. Visual Stdio 无法直接启动带有“类库输出类型”的项目若要调试此项目,请在此解决方案中添加一个引用库项目的可执行项目。将这个可执行项目设置为启动项目!
  2. SharePoint中报表选择
  3. .net使用mvc模式开发web应用 模型与视图间的数据处理
  4. echosp 销量排行 新增实际价格
  5. ECMAScript6-下一代Javascript标准
  6. Qt之QCheckBox
  7. Maven构建Web项目问题汇总
  8. java.lang.IllegalStateException: Required view &#39;text1&#39; with ID 2131492943 for field &#39;mText&#39; was not found. If this view is optional add &#39;@Nullable&#39; annotation
  9. [C++程序设计]多维数组元素的地址
  10. 返璞归真 asp.net mvc (2) - 路由(System.Web.Routing)
  11. 什么是web框架
  12. react中input自动聚焦问题
  13. python中matplotlib画图
  14. django集成ansibe实现自动化
  15. 复制程序到notepad++编辑器出现乱码的解决方法
  16. 部署crm项目
  17. 实战ELK(7)ElasticSearch常用的基本查询语句
  18. 创建jsp+Servlet+JavaBean+JDBC+MySQL项目的过程
  19. python初步学习-Python模块之 re
  20. C# 通过Exchange server 发送邮件

热门文章

  1. ANSYS热分析简介1
  2. 关于找不到指定的模块,异常来自HRESULT:0x8007007E的解决方法
  3. java之中文乱码处理
  4. Elasticsearch 6.8.4 启动报错解决方法
  5. Lesson 16 The modern city
  6. 牛茶冲天的ip命令
  7. 2 Struts2的执行流程&amp;配置文件的加载顺序
  8. 吴裕雄 Bootstrap 前端框架开发——Bootstrap 排版:强调
  9. [蓝桥杯2015决赛]穿越雷区(BFS求最短路)
  10. 第4节 Scala中的actor介绍:1、actor概念介绍;2、actor执行顺序和发送消息的方式