%Option Explicit%>
<%
Dim strLoggedIn
If Session("Authenticated") = True Then
strLoggedIn = True
Else
Response.Redirect "login.asp"
End If
%>
<%
Dim intSecID, intSecIDEdit, strFunction, strError, datdate, struser, strusername, strbody
Dim blnprivate, blnpublic
Dim strprivateChecked, strpublicChecked
Dim objRS
Set objRS = Server.CreateObject("ADODB.Recordset")
objRS.ActiveConnection = strConnect
objRS.CursorType = adOpenStatic
strusername = Session("user")
If Request.Form("AddNew") <> "True" OR Request.Form("Save") = "Don't Save" Then
intSecID = Request.QueryString("SecID")
If intSecID <> "" Then
strFunction = Request.QueryString("Function")
Select Case strFunction
Case ""
'Do Nothing
Case "edit"
'-edit"
intSecIDEdit = intSecID
objRS.LockType = adLockReadonly
objRS.Source = "SELECT * FROM member_messages WHERE ID Like " & intSecID
objRS.Open
struser = objRs("user")
datdate = objRS("date")
strbody = objRS("body")
If objRS("private") = "True" Then
blnprivate = True
strprivateChecked = " checked"
Else
blnprivate = False
End If
If objRS("public") = "True" Then
blnpublic = True
strpublicChecked = " checked"
Else
blnpublic = False
End If
objRS.Close
Case "delete"
'-delete the record
objRS.LockType = adLockOptimistic
objRS.Source = "SELECT ID FROM member_messages WHERE ID Like " & intSecID
objRS.Open
objRS.Delete
objRS.Close
End Select
End If
Else
intSecIDEdit = Request.Form("SecID")
struser = Request.Form("user")
datdate = Request.Form("date")
strbody = Request.Form("body")
If Request.Form("private") = "True" Then
blnprivate = True
strprivateChecked = " checked"
Else
blnprivate = False
End If
If Request.Form("public") = "True" Then
blnpublic = True
strpublicChecked = " checked"
Else
blnpublic = False
End If
If intSecIDEdit = "" Then
intSecIDEdit = 0
End If
objRS.LockType = adLockOptimistic
objRS.Source = "SELECT * FROM member_messages WHERE ID Like " & intSecIDEdit
objRS.Open
If intSecIDEdit = 0 Then
objRS.AddNew
End If
objRS("DateUpdated") = Now
If datdate = "" Then
strError = strError & "
You must enter a Date."
Else
objRS("date") = datdate
End If
If strbody = "" Then
strError = strError & "
You must enter a Message."
Else
objRS("body") = strbody
End If
' If struser = "" Then
' strError = strError & "
You must be logged in to post a message."
' Else
objRs("user") = struser
' End If
objRS("private") = blnprivate
objRS("public") = blnpublic
If strError = "" Then
objRS.Update
strusername = ""
datdate = ""
strbody = ""
intSecIDEdit = ""
strprivateChecked = ""
strpublicChecked = ""
Else
objRS.CancelUpdate
If intSecIDEdit = 0 Then
strFunction = "new"
Else
strFunction = "edit"
End If
End If
objRS.Close
End If
Set objRS = Nothing
If strError <> "" Then
strError = "
Error:" & strError & "
"
Else
strError = " "
End If
%>