📄 reg.asp
字号:
<%@LANGUAGE="JAVASCRIPT" CODEPAGE="936"%>
<!--#include file="Connections/mydb.asp" -->
<%
// *** Edit Operations: declare variables
// set the form action variable
var MM_editAction = Request.ServerVariables("SCRIPT_NAME");
if (Request.QueryString) {
MM_editAction += "?" + Server.HTMLEncode(Request.QueryString);
}
// boolean to abort record edit
var MM_abortEdit = false;
// query string to execute
var MM_editQuery = "";
%>
<%
// *** Redirect if username exists
var MM_flag="MM_insert";
if (String(Request(MM_flag)) != "undefined") {
var MM_dupKeyRedirect="regerror.asp";
var MM_rsKeyConnection=MM_mydb_STRING;
var MM_dupKeyUsernameValue = String(Request.Form("textfield3"));
var MM_dupKeySQL = "SELECT name FROM 表1 WHERE name='" + MM_dupKeyUsernameValue + "'"
var MM_adodbRecordset = "ADODB.Recordset";
var MM_rsKey = Server.CreateObject(MM_adodbRecordset);
MM_rsKey.ActiveConnection = MM_rsKeyConnection;
MM_rsKey.Source = MM_dupKeySQL;
MM_rsKey.CursorType=0;
MM_rsKey.CursorLocation=2;
MM_rsKey.LockType=3;
MM_rsKey.Open();
if (!MM_rsKey.EOF || !MM_rsKey.BOF) {
// the username was found - can not add the requested username
var MM_qsChar = "?";
if (MM_dupKeyRedirect.indexOf("?") >= 0) MM_qsChar = "&";
MM_dupKeyRedirect = MM_dupKeyRedirect + MM_qsChar + "requsername=" + MM_dupKeyUsernameValue;
Response.Redirect(MM_dupKeyRedirect);
}
MM_rsKey.Close();
}
%>
<%
// *** Insert Record: set variables
if (String(Request("MM_insert")) == "form2") {
var MM_editConnection = MM_mydb_STRING;
var MM_editTable = "表1";
var MM_editRedirectUrl = "regok.asp";
var MM_fieldsStr = "textfield3|value|textfield4|value|radiobutton|value|textfield6|value";
var MM_columnsStr = "name|',none,''|pass|',none,''|sex|',none,''|email|',none,''";
// create the MM_fields and MM_columns arrays
var MM_fields = MM_fieldsStr.split("|");
var MM_columns = MM_columnsStr.split("|");
// set the form values
for (var i=0; i+1 < MM_fields.length; i+=2) {
MM_fields[i+1] = String(Request.Form(MM_fields[i]));
}
// append the query string to the redirect URL
if (MM_editRedirectUrl && Request.QueryString && Request.QueryString.Count > 0) {
MM_editRedirectUrl += ((MM_editRedirectUrl.indexOf('?') == -1)?"?":"&") + Request.QueryString;
}
}
%>
<%
// *** Insert Record: construct a sql insert statement and execute it
if (String(Request("MM_insert")) != "undefined") {
// create the sql insert statement
var MM_tableValues = "", MM_dbValues = "";
for (var i=0; i+1 < MM_fields.length; i+=2) {
var formVal = MM_fields[i+1];
var MM_typesArray = MM_columns[i+1].split(",");
var delim = (MM_typesArray[0] != "none") ? MM_typesArray[0] : "";
var altVal = (MM_typesArray[1] != "none") ? MM_typesArray[1] : "";
var emptyVal = (MM_typesArray[2] != "none") ? MM_typesArray[2] : "";
if (formVal == "" || formVal == "undefined") {
formVal = emptyVal;
} else {
if (altVal != "") {
formVal = altVal;
} else if (delim == "'") { // escape quotes
formVal = "'" + formVal.replace(/'/g,"''") + "'";
} else {
formVal = delim + formVal + delim;
}
}
MM_tableValues += ((i != 0) ? "," : "") + MM_columns[i];
MM_dbValues += ((i != 0) ? "," : "") + formVal;
}
MM_editQuery = "insert into " + MM_editTable + " (" + MM_tableValues + ") values (" + MM_dbValues + ")";
if (!MM_abortEdit) {
// execute the insert
var MM_editCmd = Server.CreateObject('ADODB.Command');
MM_editCmd.ActiveConnection = MM_editConnection;
MM_editCmd.CommandText = MM_editQuery;
MM_editCmd.Execute();
MM_editCmd.ActiveConnection.Close();
if (MM_editRedirectUrl) {
Response.Redirect(MM_editRedirectUrl);
}
}
}
%>
<%
var Recordset1 = Server.CreateObject("ADODB.Recordset");
Recordset1.ActiveConnection = MM_mydb_STRING;
Recordset1.Source = "SELECT * FROM 表1";
Recordset1.CursorType = 0;
Recordset1.CursorLocation = 2;
Recordset1.LockType = 1;
Recordset1.Open();
var Recordset1_numRows = 0;
%><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<!-- TemplateBeginEditable name="doctitle" -->
<title>注册页面</title>
<!-- TemplateEndEditable --><script language="JavaScript" type="text/JavaScript">
<!--
function MM_reloadPage(init) { //reloads the window if Nav4 resized
if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);
function MM_findObj(n, d) { //v4.01
var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function MM_validateForm() { //v4.0
var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
if (val) { nm=val.name; if ((val=val.value)!="") {
if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
} else if (test!='R') { num = parseFloat(val);
if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
min=test.substring(8,p); max=test.substring(p+1);
if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
} } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }
} if (errors) alert('The following error(s) occurred:\n'+errors);
document.MM_returnValue = (errors == '');
}
//-->
</script>
<style type="text/css">
<!--
body {
background-image: url();
}
.style2 {font-size: 12px}
.style3 {font-size: 14px}
.style4 {color: #6BBC14}
.style6 {color: #FF0000}
.style7 {font-size: 14px; color: #6BBC14; }
-->
</style>
<!-- TemplateBeginEditable name="head" --><!-- TemplateEndEditable -->
</head>
<body>
<table width="927" height="832" border="0" align="left">
<tr>
<th width="244" rowspan="2" bgcolor="#FFFFFF" scope="row"><img src="board-left.gif" width="242" height="825">
<div id="Layer3" style="position:absolute; width:177px; height:165px; z-index:3; left: 49px; top: 598px;">
<div align="left" class="style3">
<p>合作站点</p>
<p><a href="http://www.sina.com.cn/"><img src="sina_logo2.gif" width="128" height="41" border="0"></a></p>
<p><a href="http://www.sohu.com/"><img src="sohu.gif" width="160" height="61" border="0"></a></p>
</div>
</div>
<div id="Layer2" style="position:absolute; width:200px; height:115px; z-index:2; left: 35px; top: 193px;"><img src="boardl1.gif" width="174" height="244"> </div> </th>
<td width="618" height="168" align="left" valign="top"><div align="left"> <img src="board.gif" width="618" height="168" hspace="0" vspace="0" align="baseline"> </div></td>
<td width="51" height="168" align="left" valign="top"><div align="right"><img src="board-right.gif" width="51" height="168" hspace="0" vspace="0" align="baseline"> </div> <div align="center"></div></td>
</tr>
<tr>
<td width="618" align="center" valign="top"><div align="left">
<div id="Layer4" style="position:absolute; width:170px; height:104px; z-index:4; left: 56px; top: 78px;">
<table width="200" border="0">
<tr>
<td colspan="2"><span class="style4">欢迎光临本站点</span></td>
</tr>
<tr>
<td width="14"> </td>
<td width="140"><span class="style4">今天是</span></td>
</tr>
<tr>
<td> </td>
<td><div align="left">
<!-- #BeginDate format:Ch2 -->2006年1月3日 <!-- #EndDate -->
</div></td>
</tr>
</table>
</div>
<div id="Layer5" style="position:absolute; width:147px; height:221px; z-index:5; left: 60px; top: 204px;">
<table width="200" height="109" border="0">
<tr>
<td height="17"><a href="index.asp"><img src="boardl3.gif" width="141" height="51" border="0"></a></td>
</tr>
<tr>
<td height="17"><a href="reg.asp"><img src="boardl5.gif" width="141" height="51" border="0"></a></td>
</tr>
<tr>
<td height="17"><img src="boardl6.gif" width="141" height="51"></td>
</tr>
<tr>
<td height="46"><a href="default.asp"><img src="boardl4.gif" width="141" height="51" border="0"></a></td>
</tr>
</table>
</div>
<div align="center">
<p class="style7">注册页面</p>
<p align="left">带<span class="style6">*</span>号为必填,否则无法完成注册</p>
</div>
</div>
<div align="left">
<form ACTION="<%=MM_editAction%>" METHOD="POST" name="form2">
<table width="401" border="0" align="center" bgcolor="#8BCC4E">
<tr>
<td width="92"><div align="right">用户名∶</div></td>
<td width="171"><input type="text" name="textfield3"></td>
<td width="116"><span class="style6">*</span></td>
</tr>
<tr>
<td><div align="right">密码∶</div></td>
<td><input type="text" name="textfield4"></td>
<td><span class="style6">*</span></td>
</tr>
<tr>
<td><div align="right">密码确认∶</div></td>
<td><input type="text" name="textfield5"></td>
<td><p><span class="style6">*</span>确认密码</p></td>
</tr>
<tr>
<td><div align="right">性别∶</div></td>
<td colspan="2"><input name="radiobutton" type="radio" value="男" checked>
男
<input type="radio" name="radiobutton" value="女">
女</td>
</tr>
<tr>
<td><div align="right">Email∶</div></td>
<td><input name="textfield6" type="text" onBlur="MM_validateForm('textfield6','','NisEmail');return document.MM_returnValue"></td>
<td><span class="style6">*</span>常用的地址</td>
</tr>
<tr>
<td> </td>
<td colspan="2"><input type="submit" name="Submit3" value="提交">
<input type="reset" name="Submit4" value="重置"></td>
</tr>
</table>
<input type="hidden" name="MM_insert" value="form2">
</form>
</div></td>
<td width="51" valign="top"><img src="board-right2.gif" width="51" height="622"></td>
</tr>
</table>
</body>
</html>
<%
Recordset1.Close();
%>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -