madHatter1
Technical User
Hello
I'm hoping somebody can help me with this query!
I have a form whose server-side vaidates the form fields before sending the visitor to a personalised 'Thank you' page.
To do this, I use:
Server.Transfer "thanks.asp"
What I would now like to do is to store whatever the visitor types in the form fields into a MSAccess database. I need to do this without redirecting the visitor to a page other than the (above) thanks.asp page, otherwise the personalised 'Thank you' will not work.
Is it possible to somehow transfer the data in the form fields to the 'thanks.asp' page and from there to store the data in the database, or is another technique better?
The script I use to store data in the database is this:
<%
' Declaring variables
Dim fullname, email, business, country, message, data_source, con, sql_insert
fullname = ChkString(Request.Form("fullname"
)
email = ChkString(Request.Form("email"
)
business = ChkString(Request.Form("business"
)
country = ChkString(Request.Form("country"
)
message = ChkString(Request.Form("message"
)
data_source = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & _
Server.MapPath("form.mdb"
sql_insert = "insert into users (fullname, email, business, country, message) values ('" & _
fullname & "', '" & email & "', '" & business & "', '" & country & "', '" & message & "')"
' Creating Connection Object and opening the database
Set con = Server.CreateObject("ADODB.Connection"
con.Open data_source
con.Execute sql_insert
con.Close
Set con = Nothing
%>
and it works, but if I paste it behind my main form (where the form fields are validated and the user then directed to 'thanks.asp'), I get errors asking me to change the names of the variables (because they are same variables I use in the main form).
Is there a way around this, please?
Many thanks
Hatter
I'm hoping somebody can help me with this query!
I have a form whose server-side vaidates the form fields before sending the visitor to a personalised 'Thank you' page.
To do this, I use:
Server.Transfer "thanks.asp"
What I would now like to do is to store whatever the visitor types in the form fields into a MSAccess database. I need to do this without redirecting the visitor to a page other than the (above) thanks.asp page, otherwise the personalised 'Thank you' will not work.
Is it possible to somehow transfer the data in the form fields to the 'thanks.asp' page and from there to store the data in the database, or is another technique better?
The script I use to store data in the database is this:
<%
' Declaring variables
Dim fullname, email, business, country, message, data_source, con, sql_insert
fullname = ChkString(Request.Form("fullname"
email = ChkString(Request.Form("email"
business = ChkString(Request.Form("business"
country = ChkString(Request.Form("country"
message = ChkString(Request.Form("message"
data_source = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & _
Server.MapPath("form.mdb"
sql_insert = "insert into users (fullname, email, business, country, message) values ('" & _
fullname & "', '" & email & "', '" & business & "', '" & country & "', '" & message & "')"
' Creating Connection Object and opening the database
Set con = Server.CreateObject("ADODB.Connection"
con.Open data_source
con.Execute sql_insert
con.Close
Set con = Nothing
%>
and it works, but if I paste it behind my main form (where the form fields are validated and the user then directed to 'thanks.asp'), I get errors asking me to change the names of the variables (because they are same variables I use in the main form).
Is there a way around this, please?
Many thanks
Hatter