这是我的网页代码,有错,单选按钮名称为“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();
%>