DW中注册页面与数据库的连接

yz007hi 2009-07-18 08:51:16
我用DW8做注册页面,windows XP,已经用ACCESS建好了数据库,数据源ODBC也已经设好了,IIS上的默认属性也已经设好了,然后我用DW设好了站点,用的是ASP.VBscript,接着把数据库连接上了,最后服务器行为插入记录都对的,最后可以预览,可是在网页上提交的信息,在自己的数据库上没记录……小弟采学网页制作,希望大家教教我,谢谢啦~,


代码如下:

<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!--#include file="Connections/tr.asp" -->
<%
' *** Edit Operations: declare variables

Dim MM_editAction
Dim MM_abortEdit
Dim MM_editQuery
Dim MM_editCmd

Dim MM_editConnection
Dim MM_editTable
Dim MM_editRedirectUrl
Dim MM_editColumn
Dim MM_recordId

Dim MM_fieldsStr
Dim MM_columnsStr
Dim MM_fields
Dim MM_columns
Dim MM_typeArray
Dim MM_formVal
Dim MM_delim
Dim MM_altVal
Dim MM_emptyVal
Dim MM_i

MM_editAction = CStr(Request.ServerVariables("SCRIPT_NAME"))
If (Request.QueryString <> "") Then
MM_editAction = MM_editAction & "?" & Server.HTMLEncode(Request.QueryString)
End If

' boolean to abort record edit
MM_abortEdit = false

' query string to execute
MM_editQuery = ""
%>
<%
' *** Insert Record: set variables

If (CStr(Request("MM_insert")) = "form1") Then

MM_editConnection = MM_tr_STRING
MM_editTable = "tbmember"
MM_editRedirectUrl = "Untitled-2.asp"
MM_fieldsStr = "textfield|value"
MM_columnsStr = "name|',none,''"

' create the MM_fields and MM_columns arrays
MM_fields = Split(MM_fieldsStr, "|")
MM_columns = Split(MM_columnsStr, "|")

' set the form values
For MM_i = LBound(MM_fields) To UBound(MM_fields) Step 2
MM_fields(MM_i+1) = CStr(Request.Form(MM_fields(MM_i)))
Next

' append the query string to the redirect URL
If (MM_editRedirectUrl <> "" And Request.QueryString <> "") Then
If (InStr(1, MM_editRedirectUrl, "?", vbTextCompare) = 0 And Request.QueryString <> "") Then
MM_editRedirectUrl = MM_editRedirectUrl & "?" & Request.QueryString
Else
MM_editRedirectUrl = MM_editRedirectUrl & "&" & Request.QueryString
End If
End If

End If
%>
<%
' *** Insert Record: set variables

If (CStr(Request("MM_insert")) = "form2") Then

MM_editConnection = MM_tr_STRING
MM_editTable = "tbmember"
MM_editRedirectUrl = "Untitled-2.asp"
MM_fieldsStr = "textfield2|value"
MM_columnsStr = "password|',none,''"

' create the MM_fields and MM_columns arrays
MM_fields = Split(MM_fieldsStr, "|")
MM_columns = Split(MM_columnsStr, "|")

' set the form values
For MM_i = LBound(MM_fields) To UBound(MM_fields) Step 2
MM_fields(MM_i+1) = CStr(Request.Form(MM_fields(MM_i)))
Next

' append the query string to the redirect URL
If (MM_editRedirectUrl <> "" And Request.QueryString <> "") Then
If (InStr(1, MM_editRedirectUrl, "?", vbTextCompare) = 0 And Request.QueryString <> "") Then
MM_editRedirectUrl = MM_editRedirectUrl & "?" & Request.QueryString
Else
MM_editRedirectUrl = MM_editRedirectUrl & "&" & Request.QueryString
End If
End If

End If
%>
<%
' *** Insert Record: set variables

If (CStr(Request("MM_insert")) = "form3") Then

MM_editConnection = MM_tr_STRING
MM_editTable = "tbmember"
MM_editRedirectUrl = "Untitled-2.asp"
MM_fieldsStr = "textfield3|value"
MM_columnsStr = "email|',none,''"

' create the MM_fields and MM_columns arrays
MM_fields = Split(MM_fieldsStr, "|")
MM_columns = Split(MM_columnsStr, "|")

' set the form values
For MM_i = LBound(MM_fields) To UBound(MM_fields) Step 2
MM_fields(MM_i+1) = CStr(Request.Form(MM_fields(MM_i)))
Next

' append the query string to the redirect URL
If (MM_editRedirectUrl <> "" And Request.QueryString <> "") Then
If (InStr(1, MM_editRedirectUrl, "?", vbTextCompare) = 0 And Request.QueryString <> "") Then
MM_editRedirectUrl = MM_editRedirectUrl & "?" & Request.QueryString
Else
MM_editRedirectUrl = MM_editRedirectUrl & "&" & Request.QueryString
End If
End If

End If
%>
<%
' *** Insert Record: construct a sql insert statement and execute it

Dim MM_tableValues
Dim MM_dbValues

If (CStr(Request("MM_insert")) <> "") Then

' create the sql insert statement
MM_tableValues = ""
MM_dbValues = ""
For MM_i = LBound(MM_fields) To UBound(MM_fields) Step 2
MM_formVal = MM_fields(MM_i+1)
MM_typeArray = Split(MM_columns(MM_i+1),",")
MM_delim = MM_typeArray(0)
If (MM_delim = "none") Then MM_delim = ""
MM_altVal = MM_typeArray(1)
If (MM_altVal = "none") Then MM_altVal = ""
MM_emptyVal = MM_typeArray(2)
If (MM_emptyVal = "none") Then MM_emptyVal = ""
If (MM_formVal = "") Then
MM_formVal = MM_emptyVal
Else
If (MM_altVal <> "") Then
MM_formVal = MM_altVal
ElseIf (MM_delim = "'") Then ' escape quotes
MM_formVal = "'" & Replace(MM_formVal,"'","''") & "'"
Else
MM_formVal = MM_delim + MM_formVal + MM_delim
End If
End If
If (MM_i <> LBound(MM_fields)) Then
MM_tableValues = MM_tableValues & ","
MM_dbValues = MM_dbValues & ","
End If
MM_tableValues = MM_tableValues & MM_columns(MM_i)
MM_dbValues = MM_dbValues & MM_formVal
Next
MM_editQuery = "insert into " & MM_editTable & " (" & MM_tableValues & ") values (" & MM_dbValues & ")"

If (Not MM_abortEdit) Then
' execute the insert
Set 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 <> "") Then
Response.Redirect(MM_editRedirectUrl)
End If
End If

End If
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
</head>

<body>
<table width="85%" height="279" border="0" cellpadding="00">
<tr>
<td>用户名:</td>
<td><form ACTION="<%=MM_editAction%>" METHOD="POST" id="form1" name="form1">
<label>
<input type="text" name="textfield" />
</label>
<input type="hidden" name="MM_insert" value="form1">
</form>
</td>
</tr>
<tr>
<td>密码:</td>
<td><form ACTION="<%=MM_editAction%>" METHOD="POST" id="form2" name="form2">
<label>
<input type="text" name="textfield2" />
</label>
<input type="hidden" name="MM_insert" value="form2">
</form>
</td>
</tr>
<tr>
<td>邮箱:</td>
<td><form ACTION="<%=MM_editAction%>" METHOD="POST" id="form3" name="form3">
<label>
<input type="text" name="textfield3" />
</label>
<input type="hidden" name="MM_insert" value="form3">
</form>
</td>
</tr>
<tr>
<td> </td>
<td><form id="form4" name="form4" method="post" action="">
<label>
<input type="submit" name="Submit2" value="提交" />
</label>
<label>
<input name="Submit" type="reset" onclick="history.go()" value="重置" />
</label>
</form>
</td>
</tr>
</table>
</body>
</html>
...全文
1245 13 打赏 收藏 转发到动态 举报
写回复
用AI写文章
13 条回复
切换为时间正序
请发表友善的回复…
发表回复
  • 打赏
  • 举报
回复
按步骤去做,去检查
不建议用DW生成的
yz007hi 2009-07-19
  • 打赏
  • 举报
回复
我也不知道怎么回事~我昨天有个问题也是类似的~后来是朋友帮我改代码采实现的~好像是数据库没连接上~可在DW里都显示正常的~哎~~
  • 打赏
  • 举报
回复
是我做出来的
yz007hi 2009-07-19
  • 打赏
  • 举报
回复
回复6楼的~我就是那样做的诶~呵呵~书上也是那样教你啊
yz007hi 2009-07-19
  • 打赏
  • 举报
回复
呵呵~好的~谢谢啦~我去那个网站看看~
  • 打赏
  • 举报
回复
菜鸟也学DW做ASP(注册系统篇):http://www.myziy.com/show.php?contentid=54
yz007hi 2009-07-19
  • 打赏
  • 举报
回复
我不会写的啊~我都是用DW生成的~你会写么~帮帮我吧~~
lzp4881 2009-07-19
  • 打赏
  • 举报
回复
<tr>
<td>密码: </td>
<td> <form ACTION=" <%=MM_editAction%>" METHOD="POST" id="form2" name="form2">
<label>
<input type="text" name="textfield2" />
</label>
<input type="hidden" name="MM_insert" value="form2">
</form>
</td>
</tr>
<tr>
<td>邮箱: </td>
<td> <form ACTION=" <%=MM_editAction%>" METHOD="POST" id="form3" name="form3">
<label>
<input type="text" name="textfield3" />
</label>
<input type="hidden" name="MM_insert" value="form3">
</form>
</td>
</tr>
------------------------------------
每个输入项都是一个form?
重新写吧,要改的太多。
yz007hi 2009-07-19
  • 打赏
  • 举报
回复
我没学过ASP的~所以不会写~呵呵~做网页是自己看DW书的~所以出了问题我就不知道怎么改了
北京不不 2009-07-19
  • 打赏
  • 举报
回复
没试过生成的。其实特简单的东西。生成的怎么这么多代码。
yz007hi 2009-07-19
  • 打赏
  • 举报
回复
好的~呵呵,也只能这样了~谢谢啦~
toury 2009-07-18
  • 打赏
  • 举报
回复
又是DW生成代码!
初学者最好不要偷这个懒,还是按部就班的自己写代码的好。即便你用DW的代码调试好了,你也是懵懵懂懂,似是而非;对你的进步没有好处。

28,407

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧