Ok, koden till sidan man skickar inläggen till databasen kommer nedan.
Sökvägen till databasen är 100% rätt.
<!-- #INCLUDE FILE="config.inc" -->
<HTML>
<HEAD>
<TITLE>Discussion Forum : by Manas Tungare</TITLE>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<LINK REL="stylesheet" HREF="forum.css">
<SCRIPT LANGUAGE="JavaScript">
<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! [url]http://javascript.internet.com[/url] -->
<!-- Begin
function topWindow(){
popup = window.open("forumkodsida.asp","" ,"height=300,width=400,scrollbars=yes, left = 575, top = 210");
}
// End -->
</SCRIPT>
</HEAD>
<BODY BGCOLOR="#FFFFFF" LEFTMARGIN="0" TOPMARGIN="0" MARGINWIDTH="0" MARGINHEIGHT="0">
<%Function Smiley(text)
text = server.HTMLEncode(text)
text = Replace(text,vbCrLf,"<br>")
text = Replace(text,":)","<img src=""smileys/glad.gif"" alt=*Glad*>")
text = Replace(text,":(","<img src=""smileys/sur.gif"" alt=*Ledsen*>")
text = Replace(text,";)","<img src=""smileys/flirtar.gif"" alt=*Flirtar*>")
text = Replace(text,":?","<img src=""smileys/confused.gif"" alt=*Förvirrad*>")
text = Replace(text,":D","<img src=""smileys/skrattar2.gif"" alt=*Skrattar*>")
text = Replace(text,":r","<img src=""smileys/1.gif"" alt=*Retas*>")
text = Replace(text,":/","<img src=""smileys/sad.gif"" alt=*Sur*>")
text = Replace(text,":o","<img src=""smileys/oj.gif"" alt=*Oj*>")
text = Replace(text,":x","<img src=""smileys/arg.gif"" alt=*Arg*>")
text = Replace(text,":s","<img src=""smileys/rodnar.gif"" alt=*Rodnar*>")
text = Replace(text,":!","<img src=""smileys/idea.gif"" alt=*Idé*>")
text = Replace(text,":k","<img src=""smileys/hearts.gif"" alt=*Pussar*>")
text = Replace(text,":8","<img src=""smileys/stir.gif"" alt=*Stirrar*>")
text = Replace(text,":z","<img src=""smileys/zzz.gif"" alt=*Sover*>")
text = Replace(text,":b","<img src=""smileys/flower.gif"" alt=*Blommor*>")
text = Replace(text,":nix","<img src=""smileys/nix.gif"" alt=*Ingen aning*>")
text = Replace(text,":g","<img src=""smileys/gaspar.gif"" alt=*Gäspar - uttråkad*>")
text = Replace(text,":sj","<img src=""smileys/sick.gif"" alt=*Sjuk*>")
Smiley = text
End Function
Function FixaTecken(str)
FixaTecken = Replace(Trim(str),"'","''")
End function%>
<TABLE WIDTH="100%" BORDER="0" CELLSPACING="0" CELLPADDING="12" BGCOLOR="#F0F0F0">
<TR VALIGN="TOP">
<TD ALIGN="center"><H3>Diskussionsforum hos <%= SiteTitle %></H3></TD>
</TR>
</TABLE>
<BR>
<%
Dim DB, InReplyTo, rsInReplyTo, IsAReply
Set DB = Connect (ForumMDB)
If Request ("Action") = "Send Message" Then
' We are into the second step: We should be inserting the records now.
' Open a Recordset so that we can insert it into the "Messages" table.
Dim rsMessage
Set rsMessage = Server.CreateObject ("ADODB.Recordset")
rsMessage.Open "Messages", DB, adOpenStatic, adLockPessimistic
' Create a new, blank record.
rsMessage.AddNew
' Now set all fields to the values we got from the form.
rsMessage ("ForumID") = Request ("ForumID")
rsMessage ("PostedBy") = Request ("PostedBy")
rsMessage ("Email") = Request ("Email")
rsMessage ("Subject") = Request ("Subject")
rsMessage ("Body") = Request ("Body")
rsMessage ("InReplyTo") = Request ("InReplyTo")
rsMessage ("Date") = Now
' And save them.
rsMessage.Update
' We also need to update the "Last Post on" and "Total Posts"
' for the corresponding forum.
Dim rsForum
Set rsForum = Server.CreateObject ("ADODB.Recordset")
rsForum.Open "SELECT Posts, LastPost FROM Forums WHERE ForumID = " & Request ("ForumID"), DB, adOpenStatic, adLockPessimistic
' Update the values with the new values:
' Increment "Posts" & set the time of the last post as Now.
rsForum ("Posts") = rsForum ("Posts") + 1
rsForum ("LastPost") = Now
rsForum.Update
' Set cookies for the "From" and "Email" fields,
' so that the user need not enter them again
' if he sends another message in the same session.
' Cookies are saved only for the session, not permanently.
Response.Cookies (SiteTitle)("PostedBy") = Request("PostedBy")
Response.Cookies (SiteTitle)("Email") = Request("Email")
' Take the user to the Forum page, so he can see the
' message he just posted.
Response.Redirect "forum.asp?ForumID=" & Request ("ForumID")
Else
' Else means, we are still in Step1,
' and we should display the form.
' Is this message in reply to some other message,
' or is it an original message?
InReplyTo = Request ("InReplyTo")
' "IsAReply" is a Boolean variable that means the following:
' True : This is in reply to a message.
' False : This is an original message.
If InReplyTo <> 0 And InReplyTo <> "" Then
IsAReply = True
Set rsInReplyTo = DB.Execute ("SELECT * FROM Messages WHERE MessageID = " & InReplyTo)
End If
' If it's not a reply, and the ForumID is not supplied,
' then something is wrong. Take the user back.
' Beware, it is NOT an error if this is a reply & the ForumID.
' If we have the original message, we can determine which Forum this belongs to.
If Not IsAReply And (Request ("ForumID") = "" Or Request ("ForumID") = 0) Then
Response.Redirect "forum.asp"
End If
%>
<TABLE WIDTH="90%" BORDER="1" CELLSPACING="0" CELLPADDING="8" ALIGN="CENTER">
<TR ALIGN="LEFT" VALIGN="TOP" BGCOLOR="#FFFFFF">
<TD COLSPAN="2">Posta ett meddelande <% If IsAReply Then Response.Write " som svar till <B>" & rsInReplyTo("Subject") & "</B> av <B>" & rsInReplyTo ("PostedBy") & "</B>"%></TD>
</TR>
<TR ALIGN="LEFT" VALIGN="TOP" BGCOLOR="#FFFFFF">
<TD COLSPAN="2">
<FORM ACTION="<%= Request.ServerVariables ("PATH_INFO") %>">
<INPUT TYPE="hidden" NAME="ForumID" VALUE="<% If IsAReply Then Response.Write rsInReplyTo ("ForumID") Else Response.Write Request ("ForumID") %>">
<INPUT TYPE="hidden" NAME="InReplyTo" VALUE="<% If InReplyTo = "" Then Response.Write "0" Else Response.Write InReplyTo %>">
<TABLE WIDTH="100%" BORDER="0" CELLSPACING="0" CELLPADDING="4" ALIGN="CENTER">
<TR ALIGN="LEFT" VALIGN="TOP">
<TD WIDTH="20%" ALIGN="RIGHT">Från:</TD>
<TD WIDTH="80%">
<INPUT TYPE="text" NAME="PostedBy" SIZE="60" MAXLENGTH="50" VALUE="<%= Request.Cookies (SiteTitle)("PostedBy") %>">
</TD>
</TR>
<TR ALIGN="LEFT" VALIGN="TOP">
<TD WIDTH="20%" ALIGN="RIGHT">Email Adress:</TD>
<TD WIDTH="80%">
<INPUT TYPE="text" NAME="Email" SIZE="60" MAXLENGTH="100" VALUE="<%= Request.Cookies (SiteTitle)("Email") %>">
</TD>
</TR>
<TR ALIGN="LEFT" VALIGN="TOP">
<TD WIDTH="20%" ALIGN="RIGHT">Ämne:</TD>
<TD WIDTH="80%">
<INPUT TYPE="text" NAME="Subject" SIZE="60" MAXLENGTH="100" VALUE="<% If IsAReply Then Response.Write "Re: " & rsInReplyTo ("Subject")%>">
</TD>
</TR>
<TR ALIGN="LEFT" VALIGN="TOP">
<TD WIDTH="20%" ALIGN="RIGHT">Meddelande:</TD>
<TD WIDTH="80%">
<TEXTAREA NAME="Body" COLS="50" ROWS="12"><% If IsAReply Then Response.Write "> " & (Replace (rsInReplyTo("Body"), vbCrLf, vbCrLf + "> "))%></TEXTAREA>
</TD>
</TR>
<TR ALIGN="LEFT" VALIGN="TOP">
<TD WIDTH="20%" ALIGN="RIGHT"> </TD>
<TD WIDTH="80%">
<INPUT TYPE="submit" NAME="Action" VALUE="Skicka">
</TD>
</TR>
</TABLE>
</FORM>
</TD>
</TR>
</TABLE>
<p align="center">
<%
End If
%>
<BR>
<font face="Tahoma" size="2"><b><a href=# onClick="topWindow()">Hur
lägger jag in smileys? Eller visar foton/bilder?</a></b></font>
<TABLE WIDTH="100%" BORDER="0" CELLSPACING="0" CELLPADDING="6" ALIGN="CENTER">
<TR ALIGN="CENTER" VALIGN="TOP">
<TD COLSPAN="2" ALIGN="LEFT">
<H6>© 2000, Manas Tungare.</H6>
</TD>
<TD ALIGN="RIGHT" WIDTH="20%">
<DIV ALIGN="RIGHT"><A HREF="http://www.manastungare.com/asp/"><IMG SRC="mt45x45.gif" WIDTH="45" HEIGHT="45" BORDER="0"></A></DIV>
</TD>
</TR>
</TABLE>
</BODY>
</HTML>