Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Hello I'm hoping somebody can he

Status
Not open for further replies.

madHatter1

Technical User
Feb 27, 2003
54
0
0
GB
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(&quot;fullname&quot;))
email = ChkString(Request.Form(&quot;email&quot;))
business = ChkString(Request.Form(&quot;business&quot;))
country = ChkString(Request.Form(&quot;country&quot;))
message = ChkString(Request.Form(&quot;message&quot;))
data_source = &quot;Provider=Microsoft.Jet.OLEDB.4.0; Data Source=&quot; & _
Server.MapPath(&quot;form.mdb&quot;)

sql_insert = &quot;insert into users (fullname, email, business, country, message) values ('&quot; & _
fullname & &quot;', '&quot; & email & &quot;', '&quot; & business & &quot;', '&quot; & country & &quot;', '&quot; & message & &quot;')&quot;

' Creating Connection Object and opening the database
Set con = Server.CreateObject(&quot;ADODB.Connection&quot;)
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
 
If I understand correctly, you have a form where users enter their values and then are redirected to a personalized &quot;Thanks&quot; page (and in between the user-input values are inserted into an Access db).

If this is so, then why can you not take the code you have above and paste it into the top of your &quot;thanks.asp&quot; page (which will then do the insert) and then have the remainder of your page run as it normally would? Assuming that your form on the user input page leads directly to the &quot;thanks.asp&quot; page, I do not see a problem here.

If I have misunderstood your intent, let me know and we can see what else can be done.

--------------------------------------------------------------------------------------------------------------------------
Human beings, who are almost unique in having the ability to learn from the experience of others, are also remarkable for their apparent disinclination to do so.
--Douglas Adams
 
Hello Chopstik

Thanks for your suggestion.

It worked! I wasn't sure that it would, because I wasn't sure that the form values were going to be passed to the 'thanks.asp' page. Anyway, they were, so thanks again!

Best wishes

hatter
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top