% check_security(1) %> <% '::::::::::::::::::: Copyright 2000-2002 Iatek. All Rights Reserved. :::::::::::::::::: ' Generated by ASPapp.com. More information can be obtained at http://www.aspapp.com ':::: page structure '-- variables are declared (dim) '-- the "request_" and "validate_" subroutines for form output '-- the "db_" subroutines for database SQL statements '-- key database fields are requested '-- the action variable is requested and handled '-- main section (this ignores value of action variable) '-- HTML begins: The 'i_header.asp' include file is displayed '-- forms and content are displayed '-- HTML ends: The 'i_footer.asp' include file is displayed '-- close database resources ':::: recommended DATABASE SCHEMA for this page ' Links: ' LinkId: int identity|int: 4 ' user_id: int identity|int: 4 ' Title: text|varchar: 60 ' URL: text|varchar: 120 ' Description: longtext|memo: 536870910 ' LinkTypeID: int identity|int: 4 ' CatID: int identity|int: 4 ' RegionID: int identity|int: 4 ' Impressions: int identity|int: 4 ' ClickThrus: int identity|int: 4 ' Email: text|varchar: 50 ' DateAdded: datetime: 8 ' DateExpire: datetime: 8 ' Priority: smallint: 2 ' DownloadURL: text|varchar: 120 ' DownloadFee: text|varchar: 40 ' AvgRating: decimal: 19 ' Ratings: int identity|int: 4 ' Display: byte: 1 dim receipt_text dim success dim DateAdded dim LinkID dim user_id dim Title dim URL dim CatID dim LinkTypeID dim Description dim DownloadURL dim DownloadFee dim Email dim SUBMIT dim add_link_sql sub request_add_link ''' request form inputs from this form DateAdded = request("DateAdded") LinkID = request("LinkID") user_id = request("user_id") Title = request("Title") URL = request("URL") CatID = request("CatID") LinkTypeID = request("LinkTypeID") Description = request("Description") DownloadURL = request("DownloadURL") DownloadFee = request("DownloadFee") Email = request("Email") SUBMIT = request("SUBMIT") end sub sub validate_add_link ''' request and validate data entered from this form DateAdded = trim(request("DateAdded")) if DateAdded = "" then error_list.add "578731","DateAdded must be specified." b_error = true end if if DateAdded <> "" AND (not isdate(DateAdded)) then error_list.add "578731date","DateAdded must be a valid date (MM/DD/YY)." b_error = true end if LinkID = trim(request("LinkID")) user_id = trim(request("user_id")) if user_id = "" then error_list.add "578741","user_id must be specified." b_error = true end if Title = trim(request("Title")) if Title = "" then error_list.add "578739","Site Title must be specified." b_error = true end if URL = trim(request("URL")) if URL = "" then error_list.add "578740","URL must be specified." b_error = true end if CatID = trim(request("CatID")) if CatID = "" then error_list.add "578742","Category must be specified." b_error = true end if LinkTypeID = trim(request("LinkTypeID")) if LinkTypeID = "" then error_list.add "578737","Resource Type must be specified." b_error = true end if Description = trim(request("Description")) if Description = "" then error_list.add "578732","Description must be specified." b_error = true end if DownloadURL = trim(request("DownloadURL")) DownloadFee = trim(request("DownloadFee")) Email = trim(request("Email")) if Email = "" then error_list.add "578735","Email must be specified." b_error = true end if SUBMIT = trim(request("SUBMIT")) end sub sub get_defaults_add_link ''' set default values for this form DateAdded = "" & now() & "" user_id = session("user_id") SUBMIT = "SUBMIT" end sub sub db_select_add_link sql = "SELECT " & _ "DateAdded, " & _ "LinkID, " & _ "user_id, " & _ "Title, " & _ "URL, " & _ "CatID, " & _ "LinkTypeID, " & _ "Description, " & _ "DownloadURL, " & _ "DownloadFee, " & _ "Email FROM Links" & _ " WHERE " & _ "Links.LinkID = " & to_sql(LinkID,"number") & "" on error resume next set rs = cn.Execute(sql) if err.number <> 0 then b_error = true error_list.add "select_data_add_link", "The data selection failed. " & err.description elseif rs.EOF then b_results = false msg_list.add "select_data_add_link", "The record was removed from the database." else DateAdded = rs("DateAdded") LinkID = rs("LinkID") user_id = rs("user_id") Title = rs("Title") URL = rs("URL") CatID = rs("CatID") LinkTypeID = rs("LinkTypeID") Description = rs("Description") DownloadURL = rs("DownloadURL") DownloadFee = rs("DownloadFee") Email = rs("Email") SUBMIT = rs("SUBMIT") end if rs.Close on error goto 0 end sub sub db_insert_add_link sql = "INSERT INTO Links" & _ "(" & _ "CatID," & _ "DateAdded," & _ "Description," & _ "DownloadFee," & _ "DownloadURL," & _ "Email," & _ "LinkTypeID," & _ "Title," & _ "URL," & _ "display," & _ "user_id" & _ ") VALUES (" & _ "" & to_sql(CatID,"number") & "," & _ "" & to_sql(DateAdded,"text") & "," & _ "" & to_sql(Description,"text") & "," & _ "" & to_sql(DownloadFee,"text") & "," & _ "" & to_sql(DownloadURL,"text") & "," & _ "" & to_sql(Email,"text") & "," & _ "" & to_sql(LinkTypeID,"number") & "," & _ "" & to_sql(Title,"text") & "," & _ "" & to_sql(URL,"text") & "," & _ "0," & _ "" & to_sql(user_id,"number") & ")" & _ "" 'response.write sql on error resume next cn.Execute(sql) if err.Number <> 0 then b_error = true error_list.add "db_insert_add_link" & err.Number ,"The database insert failed. " & err.Description else set rs = cn.Execute("SELECT @@IDENTITY") LinkID = rs(0) rs.Close msg_list.add "db_insert_add_link","The database insert was successful." end if on error goto 0 end sub sub db_update_add_link sql = "UPDATE Links SET " & _ "DateAdded = " & to_sql(DateAdded,"text") & ", " & _ "user_id = " & to_sql(user_id,"number") & ", " & _ "Title = " & to_sql(Title,"text") & ", " & _ "URL = " & to_sql(URL,"text") & ", " & _ "CatID = " & to_sql(CatID,"number") & ", " & _ "LinkTypeID = " & to_sql(LinkTypeID,"number") & ", " & _ "Description = " & to_sql(Description,"text") & ", " & _ "DownloadURL = " & to_sql(DownloadURL,"text") & ", " & _ "DownloadFee = " & to_sql(DownloadFee,"text") & ", " & _ "Email = " & to_sql(Email,"text") & " WHERE " & _ "LinkID = " & to_sql(LinkID,"number") & "" 'response.write sql on error resume next cn.execute(sql) if err.number <> 0 then b_error = true error_list.add "db_update_add_link" & err.Number ,"The database update failed. " & err.Description else end if on error goto 0 end sub sub db_delete_add_link sql = "DELETE FROM Links" & _ " WHERE " & _ "LinkID = " & to_sql(LinkID,"number") & "" 'response.write sql on error resume next cn.Execute(sql) if err.number <> 0 then b_error = true error_list.add "db_delete_add_link" & err.Number ,"The database deletion failed. " & err.Description else msg_list.add "db_delete_add_link","The record was removed." end if on error goto 0 end sub do_search = request("do_search") ''' request form keys and inputs receipt_text = request("receipt_text") success = request("success") LinkID = request("LinkID") ':: request action action = lcase(request("action")) ':: handle the action select case action case "select_add_link" ' select the requested key record from database if LinkID <> "" then db_select_add_link else b_error = true error_list.add "edit_add_link", "Specify record to select." end if case "insert_add_link" ' request form data and insert a new record into database validate_add_link if not b_error then db_insert_add_link if not b_error then response.redirect "submit.asp?success=1" end if case "update_add_link" ' request form data and update an existing database record validate_add_link if not b_error then if LinkID <> "" then db_update_add_link else b_error = true error_list.add "update_add_link", "Specify record to update." end if end if case "delete_add_link" ' delete the requested key database record if LinkID <> "" then db_delete_add_link response.redirect request.servervariables("script_name") & "?msg=The+record+was+deleted." else b_error = true error_list.add "delete_add_link", "Specify record to delete." end if end select ':: handle the default case(s) (ignores value of action parameter) if receipt_text <> "" AND success <> "" then ''' select existing record to populate form db_select_receipt_text else ''' new record end if if LinkID <> "" then ''' select existing record to populate form db_select_add_link else ''' new record ''' set default field values get_defaults_add_link end if %> <% display_errs display_msg %> <% if success = 1 then %>
| Suggest a site |