Kilden--__--__--
<%
' --------------------------------------------------------------------------------
' web:
http://www.kasp.dk' mail: kasp@kasp.dk
' icq: 113813398
' msn: admin@kasp.dk
' --------------------------------------------------------------------------------
Const adOpenKeyset = 1
Const adLockOptimistic = 3
strMode = Request.QueryString("mode")
tempConn = "PROVIDER=MSDASQL;DRIVER={Microsoft Access Driver (*.mdb)};DBQ=" & Server.MapPath("guestbook.mdb") & ";UID=admin;PWD=;"
If Request.Form("Gem") <> "" Then
strError = ""
strNavn = Trim(Request.Form("Navn"))
strEmail = Trim(Request.Form("Email"))
strKommentar = Trim(Request.Form("Kommentar"))
If Len(strNavn) = 0 Then
strError = "<li>Navn, tak !!</li>"
ElseIf validateEmail(strEmail) = False Then
strError = "<li>Din rigtige mail !!</li>"
ElseIf Len(strKommentar) = 0 Then
strError = "<li>skriv dit tag !!!</li>"
End If
If Len(strError) = 0 Then
Set rs = Server.CreateObject("ADODB.RecordSet")
strSQL = "SELECT * FROM Guestbook WHERE (ID = 0)"
rs.Open strSQL, tempConn, adOpenKeyset, adLockOptimistic
If (rs.BOF Or rs.EOF) Then
rs.AddNew
rs("Navn") = Server.HTMLEncode(strNavn)
rs("Email") = Server.HTMLEncode(strEmail)
rs("Kommentar") = Server.HTMLEncode(strKommentar)
rs("Dato") = Now()
rs.Update
End If
rs.Close
Set rs = Nothing
Else
strError = "<p><ul><font color=#000000>" & strError & "</font></ul></p>"
strMode = "add"
End If
End If
%>
<html>
<head>
<title>KASPER.PEDERSEN</title>
<LINK REL="stylesheet" HREF="./main[2].css" TYPE="text/css"/>
<STYLE TYPE="text/css">
<!--
a:active { color: #FFFFFF}
a:hover { color: #CCCCCC}
a:link { color: #CC3333; text-decoration: none}
a:visited { color: #000000; text-decoration: none}
-->
</STYLE>
</head>
<body BGCOLOR="#FFFFFF">
<div align="center"><left><STYLE TYPE="text/css">
</STYLE> <table border="0" width="100%" cellspacing="0" cellpadding="0" style="border-left: 0px solid rgb(0,0,0); border-right: 0px solid rgb(0,0,0); border-top: 0px solid rgb(0,0,0); border-bottom: 0px solid rgb(0,0,0)" ALIGN="LEFT" HEIGHT="100%">
<tr>
<td width="100%" HEIGHT="2"> </td>
</tr>
<tr VALIGN="TOP">
<td width="100%"> <FONT COLOR="#000000"><%
Select Case strMode
Case "add"
%> </FONT>
<form method="POST" action="guestbook.asp"> <table border="0" width="100%" cellspacing="0" cellpadding="2">
<tr>
<td valign="left" align="left" colspan="2"><font face="Arial, Tahoma, Verdana, Helvetica;" size="1">
<normal> <%=strError%></td>
</tr> <tr>
<td valign="left" align="left"><FONT FACE="Verdana, Arial, Helvetica, Tahoma" SIZE="1"><FONT COLOR="#000000"></FONT></FONT>
<p><FONT COLOR="#000000" FACE="BeyondControl" SIZE="1"><FONT FACE="Arial, Helvetica, Tahoma, Verdana">Navn
<BR>
<INPUT TYPE="text" NAME="Navn" SIZE="40" VALUE="<%=strNavn%>">
</FONT></FONT>
</td>
<td valign="middle" align="left"> </td>
</tr>
<tr>
<td valign="left" align="left"><FONT FACE="Verdana, Arial, Helvetica, Tahoma" SIZE="1"><FONT COLOR="#000000"></FONT></FONT>
<p><FONT COLOR="#000000" FACE="Verdana, Arial, Helvetica, Tahoma" SIZE="1"><normal><FONT COLOR="#000000" FACE="Arial, Helvetica, Tahoma, Verdana">E-mail</FONT></normal><FONT FACE="Arial, Helvetica, Tahoma, Verdana"><normal></normal><normal></normal></FONT><normal>
<BR>
<INPUT TYPE="text" NAME="Email" SIZE="40" VALUE="<%=strEmail%>">
</normal></FONT>
</td>
<td valign="left" align="left"> </td>
</tr>
<tr>
<td valign="top" align="left"><FONT FACE="Verdana, Arial, Helvetica, Tahoma" SIZE="1"><FONT COLOR="#000000"></FONT></FONT>
<p><FONT COLOR="#990000" FACE="Verdana, Arial, Helvetica, Tahoma" SIZE="1"><normal><FONT COLOR="#000000" FACE="Arial, Helvetica, Tahoma, Verdana">Kommentar</FONT></normal><FONT FACE="Arial, Helvetica, Tahoma, Verdana"><normal></normal><normal></normal></FONT><normal><BR>
<TEXTAREA ROWS="3" NAME="Kommentar" COLS="30"><%=strKommentar%></TEXTAREA></normal></FONT>
</td>
<td valign="left" align="left"> </td>
</tr>
<tr VALIGN="TOP"> <td align="left" colspan="2"><DIV ALIGN="RIGHT"><input type="submit" value="Tag" name="Gem">
<input type="button" value="Tilbage" name="Annuller" onClick="java script:location.href='guestbook.asp'"></DIV></td></tr>
</table></form>
<P><FONT COLOR="#000000"><%
Case Else
strAddLine = "<p><a href=guestbook.asp?mode=add><normal><font face=Arial, Tahoma, Verdana, Helvetica; size=1> [ Skriv dit tag ] </font></normal</a></p>"
Response.Write strAddLine
strSQL = "SELECT * FROM Guestbook ORDER BY Dato DESC;"
Set myConn = Server.CreateObject("ADODB.Connection")
myConn.Open tempConn
Set rs = myConn.Execute(strSQL)
If Not (rs.BOF Or rs.EOF) Then
Response.Write "<table width=100% border=0 cellpadding=0 cellspacing=0>"
Do While Not rs.EOF
dtmDato = rs("Dato")
dtmDato = FormatDateTime(dtmDato,vbLongDate) & " kl. " & FormatDateTime(dtmDato,vbLongTime)
Response.Write "<tr bgcolor=#FFFFFF><td width=""100%""><font face=Arial, Tahoma, Verdana, Helvetica size=1>" & dtmDato & "</td></tr>"
If Len(rs("Email")) > 0 Then
Response.Write "<tr><td><font face=Arial, Tahoma, Verdana, Helvetica size=1><normal><a href=mailto:" & rs("Email") & ">" & rs("Navn") & "</a>:</normal></td></tr>"
Else
Response.Write "<tr><td><font face=Arial, Tahoma, Verdana, Helvetica size=1><normal>" & rs("Navn") & " skriver:</normal></td></tr>"
End If
Response.Write "<tr><td><font face=Arial, Tahoma, Verdana, Helvetica size=1>" & rs("Kommentar") & "<br> </td></tr>"
rs.MoveNext
Loop
Response.Write "</table>"
Else
Response.Write "<p><font face=Arial, Tahoma, Verdana, Helvetica size=1>Ingen tag's</font></p>"
End If
myConn.Close
Set myConn = Nothing
Response.Write strAddLine
End Select
%>
<STYLE>
BODY {SCROLLBAR-FACE-COLOR: #DADADA;
SCROLLBAR-HIGHLIGHT-COLOR: #FFFFFF;
SCROLLBAR-SHADOW-COLOR: #737373;
SCROLLBAR-3DLIGHT-COLOR: #737373;
SCROLLBAR-ARROW-COLOR: #737373;
SCROLLBAR-TRACK-COLOR: #eeeeee;
SCROLLBAR-DARKSHADOW-COLOR: #F5F5F5;
overflow: auto }
</STYLE>
</FONT> </P>
</tr> <tr align="left"> <td width="100%"><normal><font face="Arial, Tahoma, Verdana, Helvetica;" size="1"><p></font></normal></td></tr>
</table></left></div>
</body>
</html>
<script language="VBScript" runat="Server">
Function validateEmail(strEmail)
validateEmail = True
If Len(strEmail) < 6 Then
validateEmail = False
End If
If InStr(1, strEmail, "@", 1) < 2 Then
validateEmail = False
End If
If InStr(1, strEmail, ".", 1) = 0 Then
validateEmail = False
End If
pos = InStr(1, strEmail, "@", 1)
If pos < 2 Then
validateEmail = False
Else
pos = InStr(pos+1, strEmail, "@")
If pos > 0 Then
validateEmail = False
End If
End If
End Function
</script>