<br />
<br />
<br />
<form name="loggain" method="post" action="index.asp?p=guestbook&do=kolla">
<b>Namn:</b>
<input type="password" name="password" size="15" />
<b>Lösenord:</b>
<input type="password" name="password2" size="15" />
<input type="submit" name="Submit" value="Logga in" />
</form>
<%End If%>
<%
If Request.Querystring("do") = "kolla" Then
Session("koll") = Request.Form("password")
Session("koll2") = Request.Form("password2")
If Session("koll") = Losen And Session("koll2") = Losen2 Then
Response.Redirect "index.asp?p=guestbook&do=ja"
Else
Response.Redirect "index.asp?p=guestbook&do=nej"
End If
End If
%>
<%If Request.Querystring("do")= "ja" AND Session("koll") = Losen AND Session("koll2") = Losen2 Then
Set Conn = Server.CreateObject("ADODB.Connection")
Set Recset = Server.CreateObject("ADODB.Recordset")
Conn.Open "Driver={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("db/gastbok.mdb")
Const perSida1 = 10
If Request.QueryString("guestbook") = "" then
page = 1
Else
page = Request.QueryString("page")
End If
RecSet.CursorLocation = 3
RecSet.CacheSize = perSida1
SQL = "SELECT * From inlagg Order By Datum DESC"
Recset.Open SQL, Conn, 1, 2
If RecSet.EOF Then%>
Ingen har skrivit i gästboken!
<hr>
<a href="index.asp?p=guestbook&do=loggaut"><b>Logga ut</b></a>
<%Else
RecSet.MoveFirst
RecSet.PageSize = perSida1
TotalPages = RecSet.PageCount
RecSet.AbsolutePage = page
Count = 0
Do While Not RecSet.EOF And Count < RecSet.PageSize %>
Inlägg: <b><%=Server.HTMLEncode(Left(RecSet("Meddelande"),40))%></b>
<a href="index.asp?p=guestbook&do=tabort&id=<%=RecSet("id")%>" onfocus=this.blur()><b>Ta
bort</b></a>
<%
Count = Count + 1
Recset.MoveNext
Loop
Recset.Close
Conn.Close
Set Recset = Nothing
Set Conn = Nothing%>
<hr />
<%
If TotalPages <> 1 Then
If (Int(page)) <> 1 Then
%>
<a href="index.asp?p=guestbook&do=ja&page=<%=(Int(page)-1)%>" onFocus="this.blur()"><b>«
Bakåt</b></a>
<%Else%>
<%End If%>
<%
For Pages = 1 To TotalPages
%>
<%If (Int(Pages)) = (Int(page)) Then%>
<b><%=Pages%></b>
<%Else%>
<a href="index.asp?p=guestbook&do=ja&page=<%=Pages%>" onFocus="this.blur()"><b><%=Pages%></b></a>
<%End If%>
<%Next%>
<%End If%>
<%
If (Int(page)) <> (Int(TotalPages)) Then
%>
<a href="index.asp?p=guestbook&do=ja&page=<%=(Int(page)+1)%>" onFocus="this.blur()"><b>Framåt
»</b></a>
<%Else%>
<%End If%>
<hr />
<a href="index.asp?p=guestbook"><b>Logga ut</b></a>
<%End If
End If%>
<%
If Request.Querystring("do")= "tabort" AND Session("koll") = Losen AND Session("koll2") = Losen2 And IsNumeric(Request.Querystring("id")) Then
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open "Driver={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("db/gastbok.mdb")
SQL="Delete * From inlagg Where ID=" & Request.Querystring("id")
Response.Write SQL
Conn.Execute(SQL)
Conn.Close
Set Conn = Nothing
Response.Redirect "index.asp?p=guestbook&do=ja"
End If
%>
Frågan#1
Vill lägga till en extra fält där man kan skriva in sin mail, det ska sparas i databasen och sen när inlägget kommer upp ska man kunna klicka på namn (mailto:)
Gästbokskoden har ni här
<% Response.Buffer = True %>
<!-- #include file="fkow3d32q.asp" -->
<script type="text/javascript">
function hidestatus(){
window.status=''
return true
}
if (document.layers)
document.captureEvents(Event.MOUSEOVER | Event.MOUSEOUT)
document.onmouseover=hidestatus
document.onmouseout=hidestatus
</script>
<%If Request.Querystring("do")= "" Then%>
<a href="index.asp?p=guestbook&do=admin" onFocus="this.blur()">Admin</a>
<hr>
<form method="post" action="index.asp?p=guestbook&do=jepp" name="gastbok" onsubmit="return tecken()">
Ditt namn:<b><br />
<input type="text" name="namn" size="25" /></b>
<br />
Hemsida:<b><br />
<input type="text" name="hemsida" size="25" /></b>
<br /><br />
Meddelande:<br />
<textarea name="Meddelande" cols="55" rows="6"></textarea><br />
<input type="submit" name="Submit2" value="Skicka" />
<input type="reset" name="Submit3" value="Rensa" />
</form>
<%
Set Conn = Server.CreateObject("ADODB.Connection")
Set Recset = Server.CreateObject("ADODB.Recordset")
Conn.Open "Driver={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("db/gastbok.mdb")
' Sidscriptet är nerladdat från [url]http://www.fatmilk.nu/[/url]
' Skrivet av Ludvig "geek" Lindblom
' [email]geek@fatmilk.nu[/email]
Const perSida = 10
If Request.QueryString("page") = "" then
page = 1
Else
page = Request.QueryString("page")
End If
RecSet.CursorLocation = 3
RecSet.CacheSize = perSida
SQL = "SELECT * From inlagg Order By Datum DESC"
Recset.Open SQL, Conn, 1, 2
If RecSet.EOF Then%>
<hr><br />
<i>Ingen har skrivit i gästboken.</i>
<%
Else
RecSet.MoveFirst
RecSet.PageSize = perSida
TotalPages = RecSet.PageCount
RecSet.AbsolutePage = page
Count = 0
Do While Not RecSet.EOF And Count < RecSet.PageSize
%>
<hr /><br />
<%If Recset("Email") <> "" Then%>
<b>Namn: <a href="mailto:<%=Recset("Email")%>" onfocus=this.blur()><%=Recset("Namn")%></a></b>
<%Else%>
<b><%=Recset("Namn")%> | <a href="<%=Recset("Hemsida")%>">hemsida</a> | <%=FormatDateTime(Recset("Datum"),2)%>
<b> - <%=FormatDateTime(RecSet("datum"),4)%> - </b><a href="http://www.leissner.se/cgi/whois?text=<%=Recset("ip")%>&c=eu" target="blank"><%=Recset("ip")%></a>
<%End If%>
</b><br />
<%=Replace(Server.HTMLEncode(RecSet("Meddelande")), vbCrLf, "<br />" )%>
<%
Count = Count + 1
Recset.MoveNext
Loop
Recset.Close
Conn.Close
Set Recset = Nothing
Set Conn = Nothing
End If
%>
<hr />
<%
If TotalPages <> 1 Then
If (Int(page)) <> 1 Then
%>
<a href="index.asp?p=guestbook&page=<%=(Int(page)-1)%>" onFocus="this.blur()"><b>«
Bakåt</b></a>
<%Else%>
<%End If%>
<%
For Pages = 1 To TotalPages
%>
<%If (Int(Pages)) = (Int(page)) Then%>
<b><%=Pages%></b>
<%Else%>
<a href="index.asp?p=guestbook&page=<%=Pages%>" onFocus="this.blur()"><b><%=Pages%></b></a>
<%End If%>
<%Next%>
<%End If%>
<%
If (Int(page)) <> (Int(TotalPages)) AND Count > 0 Then
%>
<a href="index.asp?p=guestbook&page=<%=(Int(page)+1)%>" onFocus="this.blur()"><b>Framåt
»</b></a>
<%Else%>
<%End If%>
<hr />
<%End If%>
<%If Request.QueryString("do")= "jepp" Then
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open "Driver={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("db/gastbok.mdb")
Namn = Replace(Request.Form("namn"),"'","''")
Email = Replace(Request.Form("email"),"'","''")
Hemsida = Replace(Request.Form("hemsida"),"'","''")
Meddelande = Replace(Request.Form("meddelande"),"'","''")
Datum = Now
If Hemsida <> "" Then
If Left(Hemsida,7) = "http://" Then
Hemsida = Hemsida
Else
Hemsida = "http://" & Hemsida
End If
End If
SQL="Insert Into inlagg"
SQL = SQL & "(Namn, Email, Hemsida, Meddelande, Datum, IP)"
SQL = SQL & "Values('"& Namn &"','"& Email &"','"& Hemsida &"','"&Meddelande &"',#"& Datum &"#, '" & Request.ServerVariables("REMOTE_ADDR") & "')"
Conn.Execute(SQL)
Conn.Close
Set Conn = Nothing
Response.Redirect "index.asp?p=guestbook"
End If%>
<%
If Request.Querystring("do") = "loggaut" Then
Session.Abandon
Response.Redirect "index.asp?p=guestbook"
End If
%>
<%
If Request.Querystring("do")= "nej" Then
Response.Write "<table align='center'><font color='#ffffff'><b>Fel lösenord!</b> <a href='index.asp?p=guestbook&do=admin' onfocus='this.blur()'><b>Tillbaka</b></a></table>"
End If
%>
<%If Request.Querystring("do")= "admin" Then%>
