这是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
<?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
解决方案 »
- 一个 js 获取相同name对象的问题
- 链接弹出窗口
- 验证码出错
- 谷歌浏览器如何获得<input tupe="file"... 的完整路径███████████████████████████████████████████
- 如何在Mouse点击处,正确显示一个DIV,这个DIV不要超出当前IE窗口.谢谢!
- 谁能告诉我这个JavaScript病毒有什么危害?谢谢
- 急需一段js代码,是实现类似于fram功能的,快帮忙啊。
- 这个javascript代码很有用,哪位知道怎么写?
- 关于IE回退前进键的问题
- 怎样设定打开窗口的大小
- Jquery封装再次更新-----幻灯片有文字说明效果
- jquery滚动分享
还有,用firebug看看控制台报什么错了
echo的结果跟我输入的一样,之前是能成功登录得,随后就登不进了,我在想是不是我电脑的问题