知识屋:更实用的电脑技术知识网站
所在位置:首页 > 编程技术 > PHP编程

php实战第七天

发布时间:2015-05-27 19:27:10作者:知识屋

 

 

 
 

/

 

 

 

总结一下学到的特效,获得焦点事件focus%20失去焦点事件%20blus%20按下某键事件%20keypress

 

 

[javascript]%20/%20JavaScript%20Document  //%20作者QQ%20496928838%20博客%20http://wl.125.la   $(document).ready(function(e)%20{    %20//获取用户文本框     %20var%20userName=$("#userName");    %20//获取用户密码框     %20var%20password=$("#password");    %20//获取文本框前面图片     %20var%20userimg=$("#userimg");    %20//获取密码框前面图片     %20var%20pwimg=$("#pwimg");         %20//给用户文本框置焦点     %20userName.focus();         %20//绑定用户文本框焦点事件,失去焦点事件,按下某件事件     %20userName.focus(function(){        %20userimg.css("background-position","0px");    %20}).blur(function(){        %20userimg.css("background-position","-33px");    %20}).keypress(function(e){        %20var%20key=e.which;        %20if(key==13){            %20password.focus();        %20}    %20});         %20//绑定密码文本框焦点事件,失去焦点事件,按下某件事件     %20password.focus(function(){        %20pwimg.css("background-position","-66px");             %20}).blur(function(){        %20pwimg.css("background-position","-99px");    %20}).keypress(function(e){        %20var%20key=e.which;        %20if(key==13){            %20$("#login").click();        %20}    %20});     %20//绑定登陆按钮点击事件,移入事件,移出事件     %20$("#login").click(function(){        %20//获取用户名称         %20var%20strUsetName%20=%20$("#userName").val();        %20//获取用户输入密码         %20var%20strPassword%20=%20$("#password").val();         %20var%20msg=$("#msg");                 %20$.ajax({            %20url:'admin.php?m=admin&a=login',            %20type:'POST',            %20dataType:'json',            %20data:{                %20userName:strUsetName,                %20password:strPassword            %20},            %20success:%20function(json){                %20if%20(json.state=='ok')%20{                     %20msg.html("登陆成功");                %20}else{                    %20msg.html(json.error);                   %20}            %20}                     %20});    %20}).mousemove(function(){        %20$(this).css("background-position","-138px");    %20}).mouseout(function(){        %20$(this).css("background-position","0px");    %20});               }); 

//%20JavaScript%20Document//%20作者QQ%20496928838%20博客%20http://wl.125.la$(document).ready(function(e)%20{ //获取用户文本框 var%20userName=$("#userName"); //获取用户密码框 var%20password=$("#password"); //获取文本框前面图片 var%20userimg=$("#userimg"); //获取密码框前面图片 var%20pwimg=$("#pwimg");  //给用户文本框置焦点 userName.focus();  //绑定用户文本框焦点事件,失去焦点事件,按下某件事件 userName.focus(function(){  userimg.css("background-position","0px"); }).blur(function(){  userimg.css("background-position","-33px"); }).keypress(function(e){  var%20key=e.which;  if(key==13){   password.focus();  } });  //绑定密码文本框焦点事件,失去焦点事件,按下某件事件 password.focus(function(){  pwimg.css("background-position","-66px");   }).blur(function(){  pwimg.css("background-position","-99px"); }).keypress(function(e){  var%20key=e.which;  if(key==13){   $("#login").click();  } });

 //绑定登陆按钮点击事件,移入事件,移出事件   %20$("#login").click(function(){  //获取用户名称  var%20strUsetName%20=%20$("#userName").val();  //获取用户输入密码  var%20strPassword%20=%20$("#password").val();

  var%20msg=$("#msg");    $.ajax({   url:'admin.php?m=admin&a=login',   type:'POST',   dataType:'json',   data:{    userName:strUsetName,    password:strPassword   },   success:%20function(json){    if%20(json.state=='ok')%20{      msg.html("登陆成功");    }else{     msg.html(json.error);     }   }     }); }).mousemove(function(){  $(this).css("background-position","-138px"); }).mouseout(function(){  $(this).css("background-position","0px"); });   });

请求的ajax方法

[php] %20public%20function%20login()    %20$json['state']='no';     %20if%20(!empty($_POST['userName'])%20&&%20!empty($_POST['password']))%20{        %20$userName=$_POST['userName'];        %20$password=md5($_POST['password']);        %20/*var_dumP($_POST);       %20var_dump($password);       %20var_dump($password);*/                 %20if($_SESSION['userData']=$this->db->where("userName='{$userName}'%20and%20password='{$password}'")->fine()){             %20$json['state']='ok';        %20// %20echo%20"<script>window.location.href='admin.php?m=admin&a=admin';</script>";             %20$_SESSION['login']=true;                     %20}else{             %20$json['error']='用户不存在或密码错误';        %20}     %20}else%20{        %20$json['error']='请输入用户名和密码';     %20}            %20echo%20json_encode($json);    %20//$this->display();  

  public%20function%20login()  {   $json['state']='no';

   if%20(!empty($_POST['userName'])%20&&%20!empty($_POST['password']))%20{    $userName=$_POST['userName'];    $password=md5($_POST['password']);    /*var_dumP($_POST);    var_dump($password);    var_dump($password);*/        if($_SESSION['userData']=$this->db->where("userName='{$userName}'%20and%20password='{$password}'")->fine()){

     $json['state']='ok';    // echo%20"<script>window.location.href='admin.php?m=admin&a=admin';</script>";     $_SESSION['login']=true;         }else{

     $json['error']='用户不存在或密码错误';    }

   }else%20{    $json['error']='请输入用户名和密码';

   }       echo%20json_encode($json);   //$this->display();  }

 

(免责声明:文章内容如涉及作品内容、版权和其它问题,请及时与我们联系,我们将在第一时间删除内容,文章内容仅供参考)
收藏
  • 人气文章
  • 最新文章
  • 下载排行榜
  • 热门排行榜