Chinaunix

标题: js调用登录文件怎么写代码?(在线等,急……) [打印本页]

作者: Bangel    时间: 2007-01-25 15:34
标题: js调用登录文件怎么写代码?(在线等,急……)
我的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上的密码输入地方变成用户资料等一些信息。。多谢了。。。。
在线等,请知道的老大都发表点意见
作者: 中国赢网    时间: 2007-01-25 15:39
在login.php中进行判断,如果没有登录,就显示登录界面,登录就显示登录信息。
作者: Bangel    时间: 2007-01-25 16:15
请看清楚我的代码,谢谢




欢迎光临 Chinaunix (http://bbs.chinaunix.net/) Powered by Discuz! X3.2