Hi, i have a small problem. I am trying to show the user of my website what form entries they have submitted...sort of a confirmation page. I am using a mysql db and dreamweaver. The code below shows what i have done so far...it basically checks the form with a few contraints then inserts the data into my database.
i have a feeling i need to do something with this line:
MM_editRedirectUrl = "membershipConfirmation.asp"
...but cant get my head around it.
I have incuded the following code in membershipConfirmation.asp, to try display the feilds sent. However the feilds are not referenced anywhere and so the file doesn't no where to get the values from...
Code:
memerbershipConfirmation.asp:
<html>
<head>
<title>Form Submitted</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<BODY>
<B>Thank you for filling out the form<%=Form_Forename%> !</B>
<BR><BR>
You submitted the following information:<BR>
Name: <I><%=Form_Forename%></I><BR>
Email: <I><%=Form_Surname%></I><BR>
Address1: <I><%=Form_Address1%></I><BR>
Address2: <I><%=Form_Address2%></I><BR>
Postcode: <I><%=Form_Postcode%></I><BR>
Date Of Birth: <I><%=Form_DOB%></I><BR>
Telephone: <I><%=Form_Telephone%></I><BR>
Email: <I><%=Form_Email%></I><BR>
Password: <I><%=Form_Password%></I><BR>
Username: <I><%=Form_Username%></I>
</BODY>
</HTML>
main form:
Code:
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<!--#include file="Connections/Punjab.asp" --><!-- uses this include file to find the connection string for insert statement -->
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<%'tells the script what feilds to look to, have created variables for each feild on the form
Form_Forename = Trim(Replace(Request.Form("forename"),"""",""""""))
Form_Surname = Trim(Replace(Request.Form("Surname"),"""",""""""))
Form_Address1 = Trim(Replace(Request.Form("Address1"),"""",""""""))
Form_Address2 = Trim(Replace(Request.Form("Address2"),"""",""""""))
Form_Address3 = Trim(Replace(Request.Form("Address3"),"""",""""""))
Form_PostCode = Trim(Replace(Request.Form("PostCode"),"""",""""""))
Form_DOB = Trim(Replace(Request.Form("DOB"),"""",""""""))
Form_Telephone = Trim(Replace(Request.Form("Telephone"),"""",""""""))
Form_Email = Trim(Replace(Request.Form("Email"),"""",""""""))
Form_Password = Trim(Replace(Request.Form("Password"),"""",""""""))
Form_Username = Trim(Replace(Request.Form("username"),"""",""""""))
'set validate to true intially
Validated_Form = true
IF len(Form_Forename)<2 THEN 'validation starts
Validated_Form = false
END IF
IF len(Form_Surname)<2 THEN
Validated_Form = false
END IF
IF len(Form_Email)<6 OR InStr(Form_Email,"@")=0 THEN
Validated_Form = false
END IF
'IF len(Form_Skills)<3 THEN
'Validated_Form = false
'END IF 'try to replace this one with a postcode constraint
IF NOT Validated_Form THEN
%>
<HTML>
<BODY>
Error. Click back in your browser, and check your entries! One or more fields were completed incorrectly
</HTML>
</BODY>
<%
ELSE
'Here you can insert the info to a database, or send it
'with JMail to you mail account. If you send it to a db, make sure
'to remove any possible ' chars.
%>
<HTML>
<BODY>
<B>Thank you for filling out the form<%=Form_Forename%> !</B>
<BR><BR>
You submitted the following information:<BR>
Name: <I><%=Form_Forename%></I><BR>
Email: <I><%=Form_Surname%></I><BR>
Address1: <I><%=Form_Address1%></I><BR>
Address2: <I><%=Form_Address2%></I><BR>
Postcode: <I><%=Form_Postcode%></I><BR>
Date Of Birth: <I><%=Form_DOB%></I><BR>
Telephone: <I><%=Form_Telephone%></I><BR>
Email: <I><%=Form_Email%></I><BR>
Password: <I><%=Form_Password%></I><BR>
Username: <I><%=Form_Username%></I>
</BODY>
</HTML>
<%
' *** Edit Operations: declare variables
' *** Start to insert the data into the database
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 & "?" & 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")) = "AddMember") Then
MM_editConnection = MM_Punjab_STRING
MM_editTable = "members"
MM_editRedirectUrl = "membershipConfirmation.asp"
MM_fieldsStr = "Forename|value|surname|value|Address1|value|Address2|value|Address3|value|PostCode|value|DOB|value|Telephone|value|Email|value|Password|value|Username|value"
MM_columnsStr = "Forename|',none,''|surname|',none,''|Address1|',none,''|Address2|',none,''|Address3|',none,''|Postcode|',none,''|Date_of_birth|',none,NULL|Telephone|',none,''|Email|',none,''|Password|',none,''|Username|',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
%>
<%END IF%>
</html>
Sorry the the massive thread, but its the only way i could get my point accross. Thanks.
