---
title: "gästboksfråga!"
type: "forum-thread"
url: "https://www.webforum.nu/amne/asp/79240-gästboksfråga"
topic: "ASP"
topic_url: "https://www.webforum.nu/amne/asp"
author: "eko"
published: "2003-06-09T09:28:44.000Z"
updated: "2003-06-09T14:15:29.000Z"
replies: 3
views: 239
page: 1
pages: 1
language: "sv-SE"
site: "webForum — webforum.nu"
rights: "Upphovsrätten till varje inlägg tillhör dess författare."
attribution: "Citera som: webForum, https://www.webforum.nu/amne/asp/79240-gästboksfråga"
---

# gästboksfråga!

## #1 — eko, 2003-06-09T09:28Z

Hej,

Ursäkta den långa koden men jag visste inte vilken del jag skulle posta! Ok, problemet är att jag vill att mail adresserna bara ska bli länkade om man skrivit dit sin e-mail, nu så blir det "mailto:" och namnet blir en länk även om besökaren inte skrivit något?

Kod:
\-------------------------------------------------------

\<%Response.Buffer = True%\>
\<!-- #include file="files/installning.asp" --\>
\<!-- #include file="files/link.asp" --\>

\<%Function FixaTecken(str)
  FixaTecken  = Replace(Trim(str),"'","''")
End function

Set Conn = Server.CreateObject("ADODB.Connection") 
Conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & db

If Request.Querystring("do")= "" Then%\>
\<table border="0" width="421"\>
  \<form method="post" action="guestbook.asp?do=add" name="gastbok"  onSubmit="return GbIn()"\>
    \<tr\>
      \<td\>det finns
\<% 
Set Connect = Server.CreateObject("ADODB.Connection") 
Connect.Open = "Driver={Microsoft Access Driver (\*.mdb)};DBQ="& Server.MapPath("db/guestbook.mdb") 
entries = "Select Count(\*) From inlagg" 
Set poster = Connect.Execute(entries) 
Response.Write poster(0) 
poster.Close 
Set Poster = Nothing 
%\>
inl&auml;gg i g&auml;stboken\</td\>
    \</tr\>
    \<tr\>
      \<td\>\<a href="admin.asp" target="\_blank"\>\<img src="graphic/guestname.gif" width="32" height="11" border="0"\>\</a\>\<br\>
        \<input type="text" name="namn" size="40"\>
      \</td\>
    \</tr\>
    \<tr\>
      \<td\> 
        \<div align="left"\> \<img src="graphic/guestmail.gif" width="33" height="13"\>\<br\>
          \<input type="text" name="email" size="40"\>
        \</div\>
      \</td\>
    \</tr\>
    \<tr\>
      \<td\> 
        \<div align="left"\> \<img src="graphic/guestpage.gif" width="44" height="11"\>\<br\>
          \<input type="text" name="hemsida" size="40"\>
        \</div\>
      \</td\>
    \</tr\>
    \<tr\> 
      \<td height="19" valign="top"\> 
        \<div align="left"\> \<img src="graphic/guestmess.gif" width="64" height="11"\>\<br\>
          \<textarea name="Meddelande" cols="80" rows="10"\>\</textarea\>
        \</div\>
      \</td\>
    \</tr\>
    \<tr\> 
      \<td valign="top"\> 
        \<input type="image" border="0" name="Posta inlägg" src="graphic/guestok.gif" width="33" height="13"\>
      \</td\>
    \</tr\>
  \</form\>
\</table\>
   
\<table border="0" width="421" cellpadding="2" cellspacing="0"\>
\<%Set Recset = Server.CreateObject("ADODB.Recordset")

Const gbaps = 100
Sidan = Request.QueryString("page")
If Sidan = "" then 
    sida = 1 
Else 
    sida = Sidan 
End If 

With RecSet
    .CursorLocation = 3
    .CacheSize = gbaps
End With

SQL = "Select \* From inlagg Order By datum desc"
RecSet.Open SQL, Conn

If RecSet.EOF Then%\>
\<tr\>\<td\>\<i\>Inget har skrivit i gästboken.\</i\>\</td\>\</tr\>
\<%Else

With RecSet
     .MoveFirst 
     .PageSize = gbaps
     .AbsolutePage = sida
End With

Sidor =  RecSet.PageCount

If Sidor \> 1 Then%\>
\<tr\> \<td valign="top"\>&nbsp;\</td\>\</tr\>
\<%End If

X = 0
Do While Not RecSet.EOF And X \< RecSet.PageSize%\>
\<tr\> 
\<td\>\<img src="graphic/dot2.gif" width="421" height="1"\>\</td\>
\</tr\>
\<%If Recset("Email") \<\> "" Then%\>
\<tr\> 

\<td background="graphic/bg.gif"\>
\<a href="mailto:\<%=Recset("Email")%\>"\>\<%=Recset("Namn")%\>\</a\> \| 
\<%=FormatDateTime(Recset("Datum"),4)%\> \|
\<%=FormatDateTime(Recset("Datum"),2)%\> \| 
\<a href="http://www.leissner.se/cgi/whois?text=\<%=Recset("ip")%\>&c=eu" target="blank"\>\<%=Recset("ip")%\>\</a\> \| 

\<%If RecSet("Hemsida") \<\> "" Then%\>
\<a href="\<%=RecSet("Hemsida")%\>" target="\_blank"\>\<%=Mid(RecSet("Hemsida"),8,50)%\>\</a\> 
\<%End If%\>
\</td\>
\</tr\>
\<tr\> 
\<td\>\<img src="graphic/dot2.gif" width="421" height="1"\>\</td\>
\</tr\>

\<%Else%\>

\<tr\> 
\<td background="graphic/bg.gif"\>
\<a href="mailto:\<%=Recset("Email")%\>"\>\<%=Recset("Namn")%\>\</a\> \|
\<%=FormatDateTime(Recset("Datum"),4)%\> \|
\<%=FormatDateTime(Recset("Datum"),2)%\> \| 
\<a href="http://www.leissner.se/cgi/whois?text=\<%=Recset("ip")%\>&c=eu" target="blank"\>\<%=Recset("ip")%\>\</a\> \| 

\<%If RecSet("Hemsida") \<\> "" Then%\>
\<a href="\<%=RecSet("Hemsida")%\>" target="\_blank"\>\<%=Mid(RecSet("Hemsida"),8,50)%\>\</a\> 
\<%End If%\>
\</td\>
\</tr\>
\<tr\> 
            
\<td\>\<img src="graphic/dot2.gif" width="421" height="1"\>\</td\>
\</tr\>
\<%End If%\>
\<tr\> 
\<td\>\<%=FixaLankar(RecSet("Meddelande"))%\>\</td\>
\</tr\>
\<%If Recset("svar") \<\> "" Then%\>
\<tr\> 
\<td\>&nbsp;\</td\>
\</tr\>
\<tr\> 
    \<td\>\<font color="#FF0099"\>melody club:\</font\>\<b\> \</b\>\<i\>\<%=Replace(RecSet("svar"), vbCrLf, "\<br\>")%\>\</i\>\</td\>
\</tr\>
          \<%End If%\>
          \<%X = X+ 1 
Recset.MoveNext
Loop
If Sidor \> 1 Then%\>
\<tr\> 
\<td\>\<img src="graphic/dot2.gif" width="421" height="1"\>\</td\>
\</tr\>\<tr\> 
\<td valign="top"\> 
              \<%For Sid = 1 To Sidor
         If (Int(Sid)) = (Int(sida)) Then%\>
              \<font color="#33ccff"\>\<%=Sid%\>\</font\> 
              \<%Else%\>
              \<a href="default.asp?category=guestbook&page=\<%=Sid%\>"\>\<%=Sid%\>\</a\> 
              \<%End If
     Next%\>
\</td\>
\</tr\>
\</table\>
\<%End If
Recset.Close
Set Recset = Nothing
End If

End If
If Request.QueryString("do")= "add" Then

Namn		= Request.Form("namn")
Email		= Request.Form("email")
Hemsida   	= Request.Form("hemsida")
Meddelande	= FixaTecken(Request.Form("meddelande"))
Ip   	= Request.Servervariables("REMOTE_ADDR")

If Hemsida \<\> "" Then
  If Left(Hemsida,7) = "http://" Then
    Hemsida = Hemsida
  Else
    Hemsida = "http://" & Hemsida
  End If
End If

Conn.Execute("Insert Into inlagg(Namn, Email, Hemsida, Meddelande,ip) Values('"& Namn &"','"& Email &"','"& Hemsida &"','"&Meddelande &"','"& Ip &"')")

Conn.Close
Set Conn = Nothing

Response.Redirect "default.asp?category=guestbook"

End If%\>
\-------------------------------------------------------

Mvh Erik

Permalänk: https://www.webforum.nu/p/79240

## #2 — SirPeter, 2003-06-09T09:33Z

Du hittar lösningen i din egna kod. Där du har stycket med hemsida står det:

```
<%If RecSet("Hemsida") <> "" Then%>
```

Använd dig av samma kod fast ändra så att det stämmer med e-posten bara så funkar det.
Du har det på ett ställe men inte på det andra såg jag. Testa att lägga det där med mao.

Permalänk: https://www.webforum.nu/p/1076495

## #3 — Peeer, 2003-06-09T09:34Z

Något sådant här kanske:

```
<td background="graphic/bg.gif">
<%
if len(trim(Recset("Email"))) = 0 then
Response.write Recset("Namn")
else
response.write "<a href=""mailto:" & Recset("Email") &""">" & RecSet("Namn") &"</a>"
end if
%> 
 | 
<%=FormatDateTime(Recset("Datum"),4)%> | 
<%=FormatDateTime(Recset("Datum"),2)%> | 
<a href="http://www.leissner.se/cgi/whois?text=<%=Recset("ip")%>&c=eu" target="blank"><%=Recset("ip")%></a> |
```

Snälla, använd kod-taggarna. :)

Permalänk: https://www.webforum.nu/p/1076496

## #4 — eko, 2003-06-09T14:15Z

tack, nu funkar det!

Permalänk: https://www.webforum.nu/p/1079690

---

Tråden på webben: https://www.webforum.nu/amne/asp/79240-gästboksfråga
