<% If z1_AccessLevel < 3 Then Response.Redirect "ui_index.asp?msg=you may not edit categories" End If Sub Script_Error(message) 'shouldnt ever be needed if the ui provided is used Response.Redirect "ui_index.asp?msg=" & message Response.End 'just to be sure :) End Sub Sub zAdd_Category() zobjRS.Open "categories",zobjConn,adOpenForwardOnly,adLockOptimistic,adCmdTable zobjRS.AddNew zobjRS("CategoryName") = zstrCatName zobjRS.Update zobjRS.Close End Sub Sub zEdit_Category() Dim zstrSQL zstrSQL = "SELECT * FROM categories WHERE categories.Category LIKE " & zintCatID zobjRS.Open zstrSQL,zobjConn,adOpenForwardOnly,adLockOptimistic,adCmdText zobjRS("CategoryName").Value = zstrCatName zobjRS.Update zobjRS.Close End Sub Dim zstrUpdateAction zstrUpdateAction = LCase(Trim(Request.Form("updateaction"))) If zstrUpdateAction = "edit" Then Dim zintCatID zintCatID = CInt(Trim(Request.Form("catid"))) If zintCatID = "" Or Not IsNumeric(zintCatID) Then Call Script_Error("invalid categoryid submitted for editing") End If End If Dim zstrCatName zstrCatName = Trim(Request.Form("catname")) '-- validate stuff -- If zstrCatName = "" Or Len(zstrCatName) > 50 Then Call Script_Error("Category name either not present or too long") End If '-- brain -- Dim zobjRS Set zobjRS = Server.CreateObject("ADODB.Recordset") If zstrUpdateAction = "add" Then 'makes sure password has been sent Call zAdd_Category() ElseIf zstrUpdateAction = "edit" Then Call zEdit_Category() End If Set zobjRS = Nothing zobjConn.Close Set zobjConn = Nothing Response.Redirect "ui_index.asp?msg=database updated" %>