这是php代码
<?php
session_start();
header('Content-Type:text/html;charset=gb2312');
include_once '../config.php';
include_once 'conn/conn.php';
$reback = '0';
$name = $_POST['name'];
$pwd = $_POST['pwd'];
if(!empty($name) and !empty($pwd)){
$sql = "select * from tb_member where name = '".$name."' and pwd = '".md5($pwd)."'";
$num = $conne->getRowsNum($sql);
if($num == 1){
$upsql = "update tb_member set lasttime=now() where name= '".$name."'";
$num = $conne->uidRst($upsql);
$_SESSION['name'] = $name;
$reback = '1';
}else{
$reback = '2';
}
}
echo $reback;
?>
下面是js代码
// JavaScript Document
function $(id){
return document.getElementById(id);
}
window.onload = function(){
$('lgname').focus();
$('lgbtn').onclick = chklg;
$('lgname').onkeydown = function(){
if(event.keyCode == 13){
$('lgpwd').select();
}
}
$('lgpwd').onkeydown = function(){
if(event.keyCode == 13){
$('lgchk').select();
}
}
$('lgchk').onkeydown = function(){
if(event.keyCode == 13){
 chklg();
}
}
function chklg(){
if($('lgname').value == 0){
alert('请输入用户名!');
$('lgname').focus();
return false;
}
if($('lgpwd').value == 0){
alert('请输入密码!');
$('lgpwd').focus();
return false;
}
if($('lgchk').value == ''){
alert('请输入验证码');
$('lgchk').select();
return false;
}
if($('lgchk').value != $('chknm').value){
alert('验证码输入错误');
$('lgchk').select();
return false;
}
url = 'login_chk.php?name='+$('lgname').value+'&pwd='+$('lgpwd').value;
xmlhttp.open('get',url,true);
xmlhttp.onreadystatechange = function(){
if(xmlhttp.readystate == 4){
if(xmlhttp.status == 200){
[color=#FF0000]msg = xmlhttp.responseText;[/color]
if(msg == '1'){
alert('登录成功');
window.opener.opener=null;
window.opener.close();
open('center.php?uid='+$('lgname').value,'manage','',false);
window.close();
}else if(msg == '2'){
alert('用户名或密码错误');
}else{
alert(msg);
}
}
}
}
xmlhttp.send(null);
}
$('reg').onclick = function(){
open('register.php','regist','',false);
}
}php javascript