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!

Request.QueryString question

Status
Not open for further replies.

SteveHigh

Technical User
Jan 17, 2007
158
GB
Hello

Can I ask please if the following makes sense?

I have an email form designed in Flash with the following fields:

Name (fullname) Email (email) Country (country), and Message (message).

From what I can gather, I need to use Request.QueryString to 'pull' the form field data from Flash so it can be stored in the MS Access database.

I am not sure about the following:

strfullname = Request.QueryString("fullname")
strFrom = Request.QueryString("email")
strCountry = Request.QueryString("country")
strMessage = Request.QueryString("message")

and thought I could just use the following instead:

fullname = Request.QueryString("fullname")
email = Request.QueryString("email")
country = Request.QueryString("country")
message = Request.QueryString("message")

Here is the aforementioned script, anyway:


<%
' Declare variables

Dim fullname, email, country, message, strfullname, strFrom, strCountry, strMessage


strfullname = Request.QueryString("fullname")
strFrom = Request.QueryString("email")
strCountry = Request.QueryString("country")
strMessage = Request.QueryString("message")

'Open MS Access database, store form field values, and close

set conn=Server.CreateObject("ADODB.Connection")

conn.Open "driver={Microsoft Access Driver (*.mdb)};DBQ=D:\business\Flash.mdb;"
set rs = Server.CreateObject("ADODB.recordset")

SQL="INSERT INTO users (fullname, email, country, message) VALUES ('" & _
fullname & "', '" & email & "', '" & country & "', '" & message & "')"

rs.Open SQL, conn

Set rs=Nothing

conn.Close
Set conn=Nothing
%>

Many thanks

Steve
 
Steve, whats the actual problem you are having, error message etc would be useful.

Nick
 
you are assigning the requested form values to variables using hungarian notation(prefixes)....yet when you are using the variables in your sql statement they're w/o hunagrian notation and treated as separate variables...in which have no value assigned to them...

you can name them w/o the notation of course but remember to name the same if needing that value...if you use OPTION EXPLICIT at the top of your page this will force you to see the number of different variables you have
Code:
<%OPTION EXPLICIT%>

<%
  Dim strFullname
  ' option explicit forces you to dim all variables
  ' an error would occur here...fullname is NOT
  ' the same as strFullName
  response.write strFullName & " " fullname
%>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top