| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 449 人关注过本帖
标题:菜鸟初学asp
取消只看楼主 加入收藏
glby
Rank: 1
等 级:新手上路
帖 子:6
专家分:0
注 册:2009-9-14
结帖率:100%
收藏
已结贴  问题点数:20 回复次数:2 
菜鸟初学asp
刚开始学asp,想学做个程序,请高手指导。
做了个登陆程序,不知道使用单选按钮选择身份的程序该怎么办。
两个sql数据表,一个为teacher用来存放教师信息,一个为student用来存放学生信息。
当选择学生单选项时由student验证,当选择教师单选项时由teacher验证。
图片附件: 游客没有浏览图片的权限,请 登录注册
搜索更多相关主题的帖子: 初学 asp 
2009-09-14 21:14
glby
Rank: 1
等 级:新手上路
帖 子:6
专家分:0
注 册:2009-9-14
收藏
得分:0 
谢谢各位!!!
2009-09-15 09:57
glby
Rank: 1
等 级:新手上路
帖 子:6
专家分:0
注 册:2009-9-14
收藏
得分:0 
这是我的网页代码,有错,单选按钮名称为“shenfen”,学生按钮值为1,教师按钮值为2,谢谢:
<%@LANGUAGE="JAVASCRIPT"%>
<!--#include file="Connections/conn.asp" -->
<%
var database = Server.CreateObject("ADODB.Recordset");
database.ActiveConnection = MM_conn_STRING;
database.Source = "SELECT * FROM dbo.st_info ORDER BY id ASC";
database.CursorType = 0;
database.CursorLocation = 2;
database.LockType = 1;
database.Open();
var database_numRows = 0;
%>
<%
// *** Validate request to log in to this site.
var MM_LoginAction = Request.ServerVariables("URL");
if (Request.QueryString!="") MM_LoginAction += "?" + Server.HTMLEncode(Request.QueryString);
var MM_valUsername=String(Request.Form("xuehao"));
if (MM_valUsername != "undefined") {
  var MM_fldUserAuthorization="";
  var MM_redirectLoginSuccess="home.asp";
  var MM_redirectLoginFailed="error.html";
  var MM_flag="ADODB.Recordset";
  var MM_rsUser = Server.CreateObject(MM_flag);
  MM_rsUser.ActiveConnection = MM_conn_STRING;
  MM_rsUser.Source = "SELECT xuehao, mima";
  if (MM_fldUserAuthorization != "") MM_rsUser.Source += "," + MM_fldUserAuthorization;
  MM_rsUser.Source += " FROM dbo.st_info WHERE xuehao='" + MM_valUsername.replace(/'/g, "''") + "' AND mima='" + String(Request.Form("mima")).replace(/'/g, "''") + "'";
  MM_rsUser.CursorType = 0;
  MM_rsUser.CursorLocation = 2;
  MM_rsUser.LockType = 3;
  MM_rsUser.Open();
  if (!MM_rsUser.EOF || !MM_rsUser.BOF) {
    // username and password match - this is a valid user
    Session("MM_Username") = MM_valUsername;
    if (MM_fldUserAuthorization != "") {
      Session("MM_UserAuthorization") = String(MM_rsUser.Fields.Item(MM_fldUserAuthorization).Value);
    } else {
      Session("MM_UserAuthorization") = "";
    }
    if (String(Request.QueryString("accessdenied")) != "undefined" && false) {
      MM_redirectLoginSuccess = Request.QueryString("accessdenied");
    }
    MM_rsUser.Close();
    Response.Redirect(MM_redirectLoginSuccess);
  }
  MM_rsUser.Close();
  Response.Redirect(MM_redirectLoginFailed);
}
%>
 
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>首页</title>
<style>
    <!--
     a {text-decoration:none}
     a:hover {color: red;text-decoration:none}
   -->
</style>
</head>
 
<body>
 
<table width="863" border="0" align="center" cellpadding="0" cellspacing="0">
  <!--DWLayoutTable-->
    <td height="181" align="center" valign="middle" background="picture/bg1.jpg"><form action="<%=MM_LoginAction%>" method="POST" name="form1" onSubmit="MM_validateForm('xuehao','','R');return document.MM_returnValue">
      <label><font size="2">学 号:</font>
      <input name="xuehao" type="text" id="xuehao" size="14">
      <br>
      </label>
      <label><font size="2"> 密 码:</font>
      <input name="mima" type="password" id="mima" size="14">
      <br>
      </label>
<label><font size="2">验 证:</font>
      <input name="yanzhengma" type="text" id="yanzhengma" size="14">
      <br>
      </label>
<font size="2">身份:</font>
    <label>
    <input type="radio" name="shenfen" value="1">
   <font size="2"> 学生</font></label>
    <label>
    <input type="radio" name="shenfen" value="2">
    <font size="2">教师</font><br>
    <input type="submit" name="Submit" value="提交">
    <input type="reset" name="Submit2" value="重置">
    </label>
    <p><font size="2"><a href="zhreg.asp">忘记密码?</a> <a href="reg.asp">注 册</a> <a href="xgreg.asp">修改密码</a></font></p>
<%
a = request("shenfen")  
if (a = "1") {  
    sql = "select * from st_info";
    }
else{
    sql = "select * from st_info";
    }
end if
%>

    </form>      
    <label></label></td>
    <td></td>
    <td></td>
  </tr>
   
  <tr>
    <td height="17" valign="top"><img src="picture/bg2.jpg" width="172" height="17" align="absmiddle"></td>
    <td></td>
    <td></td>
  </tr>
  <tr>
    <td height="36" valign="bottom" background="picture/rl.jpg"><!--DWLayoutEmptyCell-->&nbsp;</td>
    <td></td>
    <td></td>
  </tr>
  <tr>
    <td height="141" valign="top" background="picture/bg1.jpg"> <table width="100%" border="0" cellpadding="0" cellspacing="0">
        <!--DWLayoutTable-->
        <tr>  
          <td height="141" colspan="2" align="center" valign="middle"> <script language=JavaScript  
type=text/javascript>
<!--
calendar();
showtime();
//-->
 
          </script> </td>
        </tr>
        <tr>
          <td width="171" height="1"></td>
          <td width="229"></td>
        </tr>
    </table></td>
    <td></td>
    <td></td>
  </tr>
  <tr>
    <td height="17" valign="top"><img src="picture/bg2.jpg" width="172" height="17" align="absmiddle"></td>
    <td></td>
    <td></td>
  </tr>
  <tr>
    <td height="11"></td>
    <td></td>
    <td></td>
  </tr>
</table>
</body>
</html>
<%
database.Close();
%>
2009-09-15 10:42
快速回复:菜鸟初学asp
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.018439 second(s), 9 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved