新微赢技术网
标题:
菜鸟初学asp
[打印本页]
作者:
阿咏
时间:
2010-1-11 06:18
标题:
菜鸟初学asp
刚开始学asp,想学做个程序,请高手指导。
做了个登陆程序,不知道使用单选按钮选择身份的程序该怎么办。
两个sql数据表,一个为teacher用来存放教师信息,一个为student用来存放学生信息。
当选择学生单选项时由student验证,当选择教师单选项时由teacher验证。 附件: 只有本站会员才能下载或查看附件,请您 登录 或 注册
作者:
停淼心泪
时间:
2010-1-11 06:18
不知你要达到什么样的效果?
作者:
飘渺
时间:
2010-1-11 06:18
这是我的网页代码,有错,单选按钮名称为“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--> </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();
%>
作者:
ぱホ
时间:
2010-1-11 06:18
给单选按钮起不同的名程,判断是选的那个,然后打开不同的表。
作者:
凤蔷¤蹁跹
时间:
2010-1-11 06:18
谢谢各位!!!
作者:
鰰﹎話
时间:
2010-1-11 06:18
程序代码:
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
作者:
老肥
时间:
2010-3-6 17:05
高山仰止,莫测高深。。。。
欢迎光临 新微赢技术网 (http://bbs.weiying.cn/)
Powered by Discuz! X3.2