免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 3616 | 回复: 2
打印 上一主题 下一主题

js调用登录文件怎么写代码?(在线等,急……) [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2007-01-25 15:34 |只看该作者 |倒序浏览
我的PHP代码如下:

if ($_GET['action']=='login') {
        $username = addslashes($_POST['username']);
        $password = md5(addslashes($_POST['password']));

        $sql = "select * from $table_admin where `password` = '$password' and `username` = '$username'";
        $rs = $DB->query($sql);
        if ($DB->num_rows($rs) == 1) {
                $_SESSION['username'] = $username;
                $_SESSION['password'] = $password;
                echo "document.write(\"<table width=218 border=0 cellspacing=0 cellpadding=0>\");";
                echo "document.write(\"<tr><td height=91 valign=top background=../templates/images/huiyuan-center.jpg>\");";  
                echo "document.write(\"<tr><td><a href=login.php?action=logout>退出</a></td></tr>\")";
                echo "document.write(\"</td></tr></table>\");";
                exit;
        }else{
                header("Location:".$_SERVER['HTTP_REFERER']);
                exit;
        }
}elseif($_GET['action']=='logout') {
        @session_destroy();
        header("Location:login.php?action=ui");
        exit;
}else{
        echo "document.write(\"<table width=218 border=0 cellspacing=0 cellpadding=0>\");";
        echo "document.write(\"<tr><td height=91 valign=top background=../templates/images/huiyuan-center.jpg>\");";  
        echo "document.write(\"<form method=post action=../login.php?action=login>\");";
        echo "document.write(\"<table width=100% border=0 cellspacing=0 cellpadding=0><tr><td width=36% height=22 align=center>\");";
        echo "document.write(\"<img src=../templates/images/yonghuming.jpg width=49 height=17 /></td>\");";
        echo "document.write(\"<td colspan=2 align=left><input name=username type=text class=input id=username size=12 /></td></tr><tr>\");";
    echo "document.write(\"<td height=22 align=center><img src=../templates/images/mima.jpg width=49 height=17 /></td>\");";
    echo "document.write(\"<td colspan=2 align=left><input name=password type=password class=input id=password size=12 /></td>\");";
    echo "document.write(\"</tr><tr><td>&nbsp;</td><td width=29% align=center><input type=image name=imageField src=../templates/images/btn_bg.gif /></td>\");";
    echo "document.write(\"<td width=35% height=25 align=left><input type=image name=imageField2 src=../templates/images/btn_bg-1.gif /></td>\");";
    echo "document.write(\"</tr><tr><td>&nbsp;</td><td height=20 colspan=2 align=center>\");";
    echo "document.write(\"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;免费注册</td></tr></table></form></td></tr></table>\");";
}
?>


在index.html文件调用方式如下:
<script src=login.php?action=login></script>



请问:当我输入用户名和密码后,页面跳入了login页,我想知道怎么让页面回到index.html并且index.html上的密码输入地方变成用户资料等一些信息。。多谢了。。。。
在线等,请知道的老大都发表点意见

论坛徽章:
0
2 [报告]
发表于 2007-01-25 15:39 |只看该作者
在login.php中进行判断,如果没有登录,就显示登录界面,登录就显示登录信息。

论坛徽章:
0
3 [报告]
发表于 2007-01-25 16:15 |只看该作者
请看清楚我的代码,谢谢
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP