标题:菜鸟初学asp
只看楼主
glby
Rank: 1
等 级:新手上路
帖 子:6
专家分:0
注 册:2009-9-14
结帖率:100%
已结贴  问题点数:20 回复次数:5 
菜鸟初学asp
刚开始学asp,想学做个程序,请高手指导。
做了个登陆程序,不知道使用单选按钮选择身份的程序该怎么办。
两个sql数据表,一个为teacher用来存放教师信息,一个为student用来存放学生信息。
当选择学生单选项时由student验证,当选择教师单选项时由teacher验证。
搜索更多相关主题的帖子: 初学 asp 
2009-09-14 21:14
无诲今生
Rank: 8Rank: 8
来 自:桂林理工大学
等 级:蝙蝠侠
威 望:2
帖 子:373
专家分:726
注 册:2009-5-11
得分:5 
不知你要达到什么样的效果?

顺境逆境切莫止境,得意失意切莫在意。
2009-09-15 01:04
jingjing316
Rank: 7Rank: 7Rank: 7
等 级:黑侠
威 望:1
帖 子:293
专家分:541
注 册:2009-8-11
得分:5 
给单选按钮起不同的名程,判断是选的那个,然后打开不同的表。
2009-09-15 08:46
aspic
Rank: 17Rank: 17Rank: 17Rank: 17Rank: 17
等 级:贵宾
威 望:51
帖 子:2258
专家分:8050
注 册:2008-2-18
得分:10 
程序代码:
a = request("a") '比如这个是传递过来的身份
if a = "学生" then ’或者你设置的某个值
    sql = "select * from 你的学生表"
elseif a = "教师" then    '其实最好设置一个默认选中的 那样就只需要一个if... else...end if就可以了
    sql = "select * from 你的教师表"
else
    response.write "<script>alert('参数错误!')</script>"
end if
2009-09-15 08:48
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



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-285743-1-1.html




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

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