/*
包括的文件
*/
/*
login.php
*/
<?php
require('./mysql.php');
username=_REQUEST['username'];
passwd=_REQUEST['passwd']
session_start();
SESSION[′susername′]=username;
queryuser="select∗fromuserwhereusername=′username' and passwd = 'passwd′";db=new mysql();//实例化类mysql
result=db->query_exec(queryuser);//验证用户num_results=result−>numrows;//取得数据库中的记录行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 dbhost=′localhost′;vardb_username= 'root';
var dbpassword=′123′;vardb_database= 'new';
db=mysqlconnect( db_host,dbusername,-> db_password,−>dbdatabase);if(mysqliconnecterrno())echo"连接数据库失败!";exit;returndb;
}
}
?>
/*
效果为*/