PHP4中session登录页面的应用


Posted in PHP onJuly 25, 2008

<?php
//这个脚本是用来给用户输入口令,并判断口令是否正确的。
//如果正确则转到欢迎页面。
if ($login){
    include("../include/config.inc.php3");
    session_start();
    $right_enter='0';
    $query="select * from user_define where user_login='$user_login' and user_pass=password('$user_pass')";
    $result=@mysql_query($query,$dbconnect);
    if ($user_array=@mysql_fetch_array($result)){
        $user_id=$user_array[user_id];
        $user_name=$user_array[user_info];
        session_register("user_id");
        session_register("user_name");
        session_register("user_array");
        if(($user_array[ticket_day]) and ($user_array[ticket_num])){
            $right_enter='1';
        }
        else{
            $error_message="对不起,您没有订票的权限!";
        }
    }
    else{
        $error_message="错误!用户名错,或口令错。请重新输入。";
    }
    $log_time=date("Y-m-d H:i:s");
    $query="insert into log_record (log_time,user_login,remote_addr,right_enter,enter_function) values ('$log_time','$user_login','$REMOTE_ADDR','$right_enter','1')";
    @mysql_query($query,$dbconnect);
    if($right_enter){
        Header("Location: welcome_reserve.php3");
        exit;
    }
}
if($logout){
    session_start();
    session_unregister("user_id");
    session_unregister("user_name");
    session_unregister("user_array");
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<html>
<head>
    <title>用户登录</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link rel="stylesheet" type="text/css" href="../include/njz_common.css">
</head><body>
<p> </p>

<form name="form1" method="post" action="<?php echo $PHP_SELF; ?>" >
  <table width="289" border="1" cellspacing="0" cellpadding="1" bordercolor="#999999" align="center">
    <tr bgcolor="#999999"> 
      <td> 
        <div align="center"><font color="#FFFFFF" size="4">用户登录</font></div>
      </td>
    </tr>
    <tr>
      <td>
        <table width="267" border="0" cellspacing="0" cellpadding="5" align="center">
          <tr> 
            <td width="94"> 
              <div align="right">用户:</div>
            </td>
            <td width="169"> 
              <input type="text" name="user_login" size="16" maxlength="16" value="<?php echo $user_login; ?>">
            </td>
          </tr>
          <tr> 
            <td width="94"> 
              <div align="right">口令:</div>
            </td>
            <td width="169"> 
              <input type="password" name="user_pass" size="16" maxlength="16">
            </td>
          </tr>
          <tr> 
            <td colspan="2"> 
              <div align="center"> 
                <input type="submit" name="login" value=" 登  录 ">
                <input type="button" name="return_index" value="返回首页" onClick="form1.action='../include/goto_page.php3?dist_page=../main.php3';form1.submit();return;">
              </div>
            </td>
          </tr>
        </table>
      </td>
    </tr>
  </table>
</form>
<?php
if($error_message) echo "<center><font color='#ff0000'>$error_message</font></center>";
?>
<SCRIPT language="JavaScript">document.form1.user_login.focus();
</SCRIPT>
<p> </p>
<?php include("../footer.php3"); ?>
</body>
</html>

PHP 相关文章推荐
PHP下几种删除目录的方法总结
Aug 19 PHP
PHP中使用crypt()实现用户身份验证的代码
Sep 05 PHP
php预定义变量使用帮助(带实例)
Oct 30 PHP
PHP内置过滤器FILTER使用实例
Jun 25 PHP
ThinkPHP后台首页index使用frameset时的注意事项分析
Aug 22 PHP
php根据一个给定范围和步进生成数组的方法
Jun 19 PHP
双冒号 ::在PHP中的使用情况
Nov 05 PHP
详解WordPress开发中get_header()获取头部函数的用法
Jan 08 PHP
PHP验证码生成原理和实现
Jan 24 PHP
原生JS实现Ajax通过GET方式与PHP进行交互操作示例
May 12 PHP
关于Yii2框架跑脚本时内存泄漏问题的分析与解决
Dec 01 PHP
PHP上传图片到数据库并显示的实例代码
Dec 20 PHP
PHP 表单提交给自己
Jul 24 #PHP
PHP 得到根目录的 __FILE__ 常量
Jul 23 #PHP
jq的get传参数在utf-8中乱码问题的解决php版
Jul 23 #PHP
使用PHP socke 向指定页面提交数据
Jul 23 #PHP
php sprintf()函数让你的sql操作更安全
Jul 23 #PHP
PHP版自动生成文章摘要
Jul 23 #PHP
php array_merge下进行数组合并的代码
Jul 22 #PHP
You might like
PHP 中的一些经验积累
2006/10/09 PHP
php array_map()数组函数使用说明
2011/07/12 PHP
二招解决php乱码问题
2012/03/25 PHP
PHP下使用CURL方式POST数据至API接口的代码
2013/02/14 PHP
php读取3389的脚本
2014/05/06 PHP
php中strtotime函数用法详解
2014/11/15 PHP
PHP实现补齐关闭的HTML标签
2016/03/22 PHP
php封装单文件上传到数据库(路径)
2017/10/15 PHP
利用jQuery插件扩展识别浏览器内核与外壳的类型和版本的实现代码
2011/10/22 Javascript
onclick与listeners的执行先后问题详细解剖
2013/01/07 Javascript
JavaScript前端图片加载管理器imagepool使用详解
2014/12/29 Javascript
js的toUpperCase方法用法实例
2015/01/27 Javascript
JS+CSS实现仿雅虎另类滑动门切换效果
2015/10/13 Javascript
jquery插件jquery.LightBox.js实现点击放大图片并左右点击切换效果(附demo源码下载)
2016/02/25 Javascript
js实现上一页下一页的效果【附代码】
2016/03/10 Javascript
localStorage实现便签小程序
2016/11/28 Javascript
Vue中rem与postcss-pxtorem的应用详解
2019/11/20 Javascript
jQuery实现弹出层效果
2019/12/10 jQuery
微信小程序新闻网站详情页实例代码
2020/01/10 Javascript
[43:51]2018DOTA2亚洲邀请赛3月30日 小组赛B组 EG VS Secret
2018/03/31 DOTA
python实现搜索本地文件信息写入文件的方法
2016/02/22 Python
Python去除、替换字符串空格的处理方法
2018/04/01 Python
python 利用栈和队列模拟递归的过程
2018/05/29 Python
python实现雨滴下落到地面效果
2018/06/21 Python
Django rest framework工具包简单用法示例
2018/07/20 Python
Python3.5常见内置方法参数用法实例详解
2019/04/29 Python
基于pytorch的lstm参数使用详解
2020/01/14 Python
CSS3实现网站商品展示效果图
2020/01/18 HTML / CSS
HTML5实现签到 功能
2018/10/09 HTML / CSS
俄罗斯香水在线商店:AromaCode
2019/12/04 全球购物
会计自荐信范文
2014/03/09 职场文书
公司建议书怎么写
2014/05/15 职场文书
国家奖学金获奖感言
2014/08/16 职场文书
销售督导岗位职责
2015/04/10 职场文书
2015年员工试用期工作总结
2015/05/28 职场文书
浅析Python OpenCV三种滤镜效果
2022/04/11 Python