php 登陆动作详解
来源:互联网 发布:3dsmax 安装mac 编辑:程序博客网 时间:2024/05/23 15:05
<?php class LoginAction extends Action { function index(){ $this->display(); } function do_login(){ //获取用户名和密码信息,和数据库中比对 // echo 111111111; // dump($_POST); // dump($_SESSION); $username=$_POST['username']; $password=$_POST['password']; $code=$_POST['code']; if($_SESSION['verify']!==md5($code)){$this->error('验证码错误');}/* else{$this->show('登录成功');} */$m=new Model('user');$where['username']=$username;//$where['password']=$password;$i=$m->where($where)->count();if ($i>0){$this->redirect('User/index');}else{$this->error('该用户不存在');}; } }?>///调用Login/index Login模块的index方法,登陆页面内容:<!-- form 表单 table 表格 td 单元格 tr 行标签 --><!doctype html><html lang="en"> <head> <meta name="Generator" content="EditPlus?"> <meta name="Author" content=""> <meta name="Keywords" content=""> <meta name="Description" content=""> <title>Document</title> <link rel='stylesheet' type='text/css' href='__PUBLIC__/Css/login.css'/> <link rel='stylesheet' type='text/css' href='__PUBLIC__/Css/basic.css'/> <script src="__PUBLIC__/Js/login.js"></script> </head> <body> <!doctype html><html lang="en"> <head> <meta name="Generator" content="EditPlus?"> <meta name="Author" content=""> <meta name="Keywords" content=""> <meta name="Description" content=""> <title>Document</title> </head> <body> <center> <h1>中均运维管理平台</h1> <!--图片标签--><img class="img_bk" src="__PUBLIC__/Images/scan.jpg"/> </center> <!--表单提交--> <form action='__URL__/do_login' method='post' name="myForm"><center><table cellspacing="0" cellpadding="0"><tr><td class="td1">用户名:</td><td><input type="text" name="username"/></td><td class="td3"></td><tr/><tr><td class="td1">密码:</td><td><input type="password" name="password"/></td><td class="td3"></td><tr/><tr><td class="td1">验证码:</td><td> <input type='text' name='code' /></td><td class="td3"><img src="__APP__/Public/code" onclick='this.src=this.src+"?"+Math.random()'/></td></tr><center><tr><td class="td1"></td><!-- <td align="center" ><input type="submit" name="login" value="login" /></td> --><td><img src="__PUBLIC__/Images/login.jpg" onclick="login()"/></td><td class="td3"></td></tr><center/><center/> </form> </body></html> </body></html>//__PUBLIC__/Js/login.js 调用的js来自,利用的login方法 <script src="/thinkphp/Public/Js/login.js"></script> function login() { var ou=document.myForm.username;var op=document.myForm.password;var oc=document.myForm.code;if (ou.value==''||op.value==''||oc.value==''){alert ('用户名,密码或者验证码不能为空');}else{document.myForm.submit();}}POST 请求调用的方法:__URL__/do_login <!--表单提交--> <form action='/thinkphp/index.php/Login/do_login' method='post' name="myForm">
0 0
- php 登陆动作详解
- php登陆模块详解($_SESSION | $_POST | $_SERVER)
- PHP Yii框架自定义动作(Action)用法详解
- JSP标准动作详解
- JSP动作元素详解
- JSP动作元素详解
- JSP动作元素详解
- JSP动作元素详解
- JSP动作元素详解
- JSP动作元素详解
- JSP动作元素详解
- JSP六个动作详解...
- cocos2dx 动作详解
- Cocos2d-x动作详解
- cocos2dx 常用动作详解
- JSP六个动作详解
- jsp动作命令详解
- JSP六个动作详解...
- C#小伎俩获取本地或远程磁盘使用信息
- HDU1164 Eddy's research I(解法二)
- 打劫房屋 II
- 第九周周赛——周赛兼组队赛第一场题解(出自HDU5443,本oj,HDU 5667,poj1742,codeforces 664A,BUNOJ 28199)
- LightOJ - 1425 The Monkey and the Oiled Bamboo (水)
- php 登陆动作详解
- 射箭
- 配置文件的读写
- LUA基本函数库
- 浅谈JavaScript(一)
- poj 2185 Milking Grid
- 函数指针的应用比较排序与冒泡排序指针完成
- NYOJ 17 单调递增最长子序列
- C语言数据结构学习网站