验证方面写的不是很完整,正在完善当中

<?php
/**
* Created by dreamcms.
* User: Administrator
* Date: 2016/9/5
* Time: 17:15
*/ namespace Admin\Controller;
use Think\Controller; class LoginController extends CommonController{ //视图显示
public function Login(){
$this->display();
} /**
* 登录验证
*/
public function Check_Login(){
//验证码检测
$names=$_POST['Captcha'];
if($this->check_verify($names)==false){
$data['error']=1;
$data['msg']="验证码错误";
$this->ajaxReturn($data);
}
//用户检测
$uname=I('post.username');
$upasswd=I('post.password');
$map['uname']=$uname;
$map['state']=1;
$logins=M('login')->where($map)->find();
if($logins)
{
if($logins['upasswd']!=$upasswd)
{
$data['error']=1;
$data['msg']="密码错误";
$this->ajaxReturn($data);
}
session("admin",$logins); var_dump($logins);
redirect(U('Index/index'));
} } /**
* 验证码生成
*/
public function Verifys()
{
$config=array(
'fontSzie'=>30, //验证码字体大小
'length'=>4,//验证码位数
'useImgBg'=>true ); $verify=new \Think\Verify($config);
$verify->useZh=true; $verify->zhSet="梦起软件工作室";
$verify->fontttf='simhei.ttf';
$verify->entry(); } /**
* 验证码检测
*/
public function check_verify($code,$id="")
{
$verify=new \Think\Verify();
return $verify->check($code,$id);
}
/**
* 退出登录
*/
public function out_login(){
session("admin",null);
redirect(U('Login/login'));
}
}

  前台页面

<html>
<!DOCTYPE html>
<html lang="en" class="no-js"> <head> <meta charset="utf-8">
<title>登录(Login)</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="">
<meta name="author" content=""> <!-- CSS -->
<link rel="stylesheet" href="__PUBLIC__/admin/login/css/reset.css"> <link rel="stylesheet" href="__PUBLIC__/admin/login/css/style.css"> <!-- HTML5 shim, for IE6-8 support of HTML5 elements -->
<!--[if lt IE 9]>
<script src="__PUBLIC__/admin/login/js/html5.js"></script>
<![endif]--> </head>
<style> * { margin:0; padding:0; }
body { background:#111; height:100%; }
img { border:none; } #supersized-loader { position:absolute; top:50%; left:50%; z-index:0; width:60px; height:60px; margin:-30px 0 0 -30px; text-indent:-999em; background:url("__PUBLIC__/admin/login/img/progress.gif") no-repeat center center;} #supersized { display:block; position:fixed; left:0; top:0; overflow:hidden; z-index:-999; height:100%; width:100%; }
#supersized img { width:auto; height:auto; position:relative; display:none; outline:none; border:none; }
#supersized.speed img { -ms-interpolation-mode:nearest-neighbor; image-rendering: -moz-crisp-edges; } /*Speed*/
#supersized.quality img { -ms-interpolation-mode:bicubic; image-rendering: optimizeQuality; } /*Quality*/ #supersized li { display:block; list-style:none; z-index:-30; position:fixed; overflow:hidden; top:0; left:0; width:100%; height:100%; background:#111; }
#supersized a { width:100%; height:100%; display:block; }
#supersized li.prevslide { z-index:-20; }
#supersized li.activeslide { z-index:-10; }
#supersized li.image-loading { background:#111 url("__PUBLIC__/admin/login/img/progress.gif") no-repeat center center; width:100%; height:100%; }
#supersized li.image-loading img{ visibility:hidden; }
#supersized li.prevslide img, #supersized li.activeslide img{ display:inline; } #supersized img { max-width: none !important } </style>
<body> <div class="page-container">
<h1>梦起工作室后台登录(Login)</h1>
<form action="{:U('Login/Check_Login')}" method="post">
<input type="text" name="username" class="username" placeholder="请输入您的用户名!">
<input type="password" name="password" class="password" placeholder="请输入您的用户密码!">
<input type="Captcha" class="Captcha" name="Captcha" placeholder="请输入验证码!"><img src="{:U('Login/Verifys')}" width="120" height="43" name="verify" style="position: relative; top: 20px;" />
<button type="submit" class="submit_button">登录</button>
<div class="error"><span>+</span></div>
</form> </div> <!-- Javascript -->
<script src="__PUBLIC__/admin/login/js/jquery-1.8.2.min.js" ></script>
<script src="__PUBLIC__/admin/login/js/supersized.3.2.7.min.js" ></script>
<script src="__PUBLIC__/admin/login/js/supersized-init.js" ></script>
<script src="__PUBLIC__/admin/login/js/scripts.js" ></script> </body>
</html>

  

ThinkPHP之登录验证的更多相关文章

  1. ThinkPHP实例—实现登录验证

    ThinkPHP 验证 本篇我们将运用商城实例讲解一下如何运用ThinkPHP做一个登录验证 我们的框架目录结构如下图所示: 其中 app  文件夹就是我们的应用文件夹  它的目录结构如下所示 其中 ...

  2. PHP通过session id 实现session共享和登录验证的代码

    先说说,这个机制的用途吧,到现在为止战地知道这个机制有两个方面的用途: 首先,多服务器共享session问题,这个大家应该都能够理解的,当一个网站的用户量过大,就会使用服务器集群,例如专门有一个登录用 ...

  3. ASP.NET MVC 登录验证

     好久没写随笔了,这段时间没 什么事情,领导 一直没安排任务,索性 一直在研究代码,说实在的,这个登录都 搞得我云里雾里的,所以这次我可能也讲得不是 特别清楚,但是 我尽力把我知道的讲出来,顺便也对自 ...

  4. Shiro安全框架入门篇(登录验证实例详解与源码)

    转载自http://blog.csdn.net/u013142781 一.Shiro框架简单介绍 Apache Shiro是Java的一个安全框架,旨在简化身份验证和授权.Shiro在JavaSE和J ...

  5. 练习:python 操作Mysql 实现登录验证 用户权限管理

    python 操作Mysql 实现登录验证 用户权限管理

  6. AD域登录验证

    AD域登录验证 作者:Grey 原文地址:http://www.cnblogs.com/greyzeng/p/5799699.html 需求 系统在登录的时候,需要根据用户名和密码验证连接域服务器进行 ...

  7. ASP.NET MVC4 Forms 登录验证

    Web.config配置: 在<system.web>节下: <authentication mode="Forms"> <forms loginUr ...

  8. MVC前台页面做登录验证

    最近接触了一个电商平台的前台页面,需要做一个登录验证,具体情况是:当用户想要看自己的订单.积分等等信息,就需要用户登录之后才能查询,那么在MVC项目中我们应该怎么做这个前台的验证呢? 1.我在Cont ...

  9. [MVC学习笔记]5.使用Controller来代替Filter完成登录验证(Session校验)

          之前的学习中,在对Session校验完成登录验证时,通常使用Filter来处理,方法类似与前文的错误日志过滤,即新建Filter类继承ActionFilterAttribute类,重写On ...

随机推荐

  1. 【javaweb学习】XML和约束模式

    xml:可扩展标记语言,w3c组织发布的,用于保存有关系的数据,作为配置文件,描述程序模块之间的关系 <?xml version="1.0" encoding="g ...

  2. Sublime Text的心得经验。 全面

    Sublime Text的心得经验.jikeytang/sublime-text · GitHub

  3. Chrome 控制台使用大全

    Chrome的开发者工具已经强大到没朋友的地步了,特别是功能丰富界面友好的console 一.console.log 将输出到控制台的信息进行分类会更好: console.log();    普通信息 ...

  4. 软件测试基础homework3

    //本次的作业为/******************************************************* * Finds and prints n prime integers ...

  5. Android 使用js调用Java

    效果如: 主要用到一个接口类:MyObject package com.example.jsdemo; import android.content.Context; import android.s ...

  6. delphi之事件

    delphi的事件如上图所示: 图中oncloseup代表的是日期选择下拉框关闭时触发的事件. //事件定义 procedure Ondatechange(Sender: TObject); //事件 ...

  7. 在 Apache Ant中设置Proxy服务器

    <target name="proxy"> <property name="proxy.host" value="https://m ...

  8. ebs r12 -- adadmin: error while loading shared libraries: libclntsh.so.10.1

    安装EBS R12.2增加中文字符集时,运行$AU_TOP/bin/adadmin出错: $ adadmin adadmin: error while loading shared libraries ...

  9. rosetta2014/2015安装时出现INCLUDE(keyerror)错误,解决。

    错误: KeyError: 'INCLUDE' 使编译出错 解决方法: [usrname@host source]$ vim tools/build/site.settings 注释# "i ...

  10. memcpy内存复制

    memcpy(predata,frame,1920*1080*4);