jarv
01-06-2010, 10:30 AM
I would like to validate my Add form, is there a way of putting my fiorst bit of code inside my second bit of code?
I need to say something like request.form("Add") and then request.form("size")?!
<!-- Form validation -->
<%
IF request.form("size") = "" THEN
response.write("Please enter a valid size number")
END IF
IF request.form("colour") = "" THEN
response.write("Please enter a valid colour")
END IF
IF request.form("stock") = "" THEN
response.write("Please enter a valid stock number")
END IF
%>
<!-- END Form validation -->
<%
If Request.Form("add") = "Add" Then
sql = "INSERT INTO tblProductOptions (ProductID, `Size`, Colour, Stock, ComingSoon) VALUES (" & _
"" & Strip(Request.Form("id")) & ", " & _
"" & Strip(Request.Form("size")) & ", " & _
"'" & Strip(Request.Form("colour")) & "', " & _
"" & Strip(Request.Form("stock")) & ", " & _
"" & iif(IsNumeric(Strip(Request.Form("ComingSoon"))), 1, 0) & "" & _
");"
Set conn = Server.CreateObject("ADODB.Connection")
conn.ConnectionString = MM_CON_Database_STRING
conn.open
response.write sql
conn.Execute sql
Set conn = Nothing
Response.Redirect("index.asp?id=" & Request.Form("ID"))
End If
I need to say something like request.form("Add") and then request.form("size")?!
<!-- Form validation -->
<%
IF request.form("size") = "" THEN
response.write("Please enter a valid size number")
END IF
IF request.form("colour") = "" THEN
response.write("Please enter a valid colour")
END IF
IF request.form("stock") = "" THEN
response.write("Please enter a valid stock number")
END IF
%>
<!-- END Form validation -->
<%
If Request.Form("add") = "Add" Then
sql = "INSERT INTO tblProductOptions (ProductID, `Size`, Colour, Stock, ComingSoon) VALUES (" & _
"" & Strip(Request.Form("id")) & ", " & _
"" & Strip(Request.Form("size")) & ", " & _
"'" & Strip(Request.Form("colour")) & "', " & _
"" & Strip(Request.Form("stock")) & ", " & _
"" & iif(IsNumeric(Strip(Request.Form("ComingSoon"))), 1, 0) & "" & _
");"
Set conn = Server.CreateObject("ADODB.Connection")
conn.ConnectionString = MM_CON_Database_STRING
conn.open
response.write sql
conn.Execute sql
Set conn = Nothing
Response.Redirect("index.asp?id=" & Request.Form("ID"))
End If