background image

一个简单的

php 用户登陆模块

包括如下页面:
left.php   登陆页面
userlogin.php  验证功能
login.php   注销功能
config.auth.php 数据库连接功能
说明:
left.php 通过 post 提交信息给 userlog.php 处理,userlog.php 调用 config.auth.php 连接数据库
进行数据处理,然后把结果返回

left.php,logout.php 就只是注销 session 功能。没有加入

cookie,还暂时不需要保存 cookie!
1,left.php

代码示例

:

<!DOCTYPE 

html 

PUBLIC 

"-//W3C//DTD 

XHTML 

1.0 

Transitional//EN" 

"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>登陆系统</title>
</head>
<body>
<?php
    session_start(); 
    if ($_SESSION[username]) { 
    ?>
    <form id="form3" name="form3" method="post" action="">
    <table width="150" border="1">
        <tr>
          <td width="64">当前用户</td>
          <td width="70"><?php echo $_SESSION[username];?></td>
        </tr>
        <tr>
          <td colspan="2"><div align="center"><a href="logout.php">注销</a></div></td>
        </tr>
      </table>
    </form>
    <?php
    }else { 
    ?>
    <form id="form1" name="form1" method="post" action="userlogin.php">
      <table width="150" border="1">
        <tr>
          <td width="64">用户</td>