If Request Command submitting values
am 16.12.2004 06:39:59 von delete007
Hi all, I'm using the "If Request" command to submit data from a form to a
database only when the form is submitted. But for some reason the form data
is submitted to the database on page load. Causing a problem because the
values submitted are null.
Q1) Can anyone look at the code and tell me how to prevent this?
<% If Request("SubmitVehicle") <> "" Then %>
<%AddVehicle__StrVehicle = Request("Vehicle")%>
<% End If %>
<%
set AddVehicle = Server.CreateObject("ADODB.Command")
AddVehicle.ActiveConnection = MM_CertainCars_STRING
AddVehicle.CommandText = "INSERT INTO TestVehicleTable (Vehicle,
VehicleValue) VALUES ('" + Replace (AddVehicle__StrVehicle, "'", "''") +
"','" + Replace(AddVehicle__StrVehicle & "Model", "'", "''") + "') "
AddVehicle.CommandType = 1
AddVehicle.CommandTimeout = 0
AddVehicle.Prepared = true
AddVehicle.Execute()
%>
Re: If Request Command submitting values
am 16.12.2004 07:53:17 von gerard.leclercq
If you use in your form METHOD='POST' then the variables are in
Request.Form("myVariable")
if you use METHOD='GET'
Then you need to use Request.QueryString("MyVariable")
<%
If Request.Form("SubmitVehicle") <> "" Then
addVehicle__StrVehicle = Request("Vehicle")
End If
%>
Do not <% %> use in each line. Only where ASP code starts and stops.
GĂ©rard.
You can learn a lot about ASP on
http://www.w3schools.com/asp
"Paul" schreef in bericht
news:Pc9wd.21656$A6.17138@fe2.news.blueyonder.co.uk...
> Hi all, I'm using the "If Request" command to submit data from a form to a
> database only when the form is submitted. But for some reason the form
> data is submitted to the database on page load. Causing a problem because
> the values submitted are null.
>
> Q1) Can anyone look at the code and tell me how to prevent this?
>
> <% If Request("SubmitVehicle") <> "" Then %>
> <%AddVehicle__StrVehicle = Request("Vehicle")%>
> <% End If %>
>
>
> <%
>
> set AddVehicle = Server.CreateObject("ADODB.Command")
> AddVehicle.ActiveConnection = MM_CertainCars_STRING
> AddVehicle.CommandText = "INSERT INTO TestVehicleTable (Vehicle,
> VehicleValue) VALUES ('" + Replace (AddVehicle__StrVehicle, "'", "''") +
> "','" + Replace(AddVehicle__StrVehicle & "Model", "'", "''") + "') "
> AddVehicle.CommandType = 1
> AddVehicle.CommandTimeout = 0
> AddVehicle.Prepared = true
> AddVehicle.Execute()
>
> %>
>
>
>