Hjælp til script fejl.
Hejsa, jeg har indsat et gæstebog script i mit design, men jeg for denne her fejl:Microsoft VBScript compilation error '800a0411'
Name redefined
/side/gb_skriv.asp, line 135
Dim myConn
----^
linje 135 ser sådan her ud:
Dim myConn
Scriptet virker fint, hvis jeg køre det på en ren side og ikke i mit design. Så vil høre om der er en som kan tricke den og finde fejlen på hvad jeg skal have rettet til.
Min side med gæstebogen ser sådan her ud:
<!-- #include file="admin/DBconn.asp" -->
<!-- #include file="admin/config/config_2.asp" -->
<%
Dim rsWeblog
Dim rsComments
Dim rsCat
%>s
<%
Response.Buffer = "True"
' -> DETTE ER VARIABLERNE TIL DATABASEN.
Dim myConn
Dim strSQL
' -> DSNLess FORBINDELSE TIL DATABASEN.
Set myConn = Server.CreateObject("ADODB.Connection")
myConn.Open "Driver={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("../../db/gb.mdb")
' -> DETTE GODKENDER E-MAIL ADRESSEN.
Function GodkendEmail(AfsenderEmail)
' -> DETTE ER VARIABLERNE TIL GODKENDELSEN.
Dim EmailGodkendt
Dim EmailOpdeling
Dim EmailKarakterer
Dim TilladteKarakterer
Dim iLoopCounter
EmailGodkendt = "True"
' -> DETTE ER DE TILLADTE KARAKTERER.
TilladteKarakterer = "abcdefghijklmnopqrstuvwxyz.-_@"
' -> DETTE OPDELER E-MAIL ADRESSEN I TO DELE VED "@" TEGNET.
EmailOpdeling = Split(AfsenderEmail, "@")
' -> DETTE CHECKER, AT E-MAIL ADRESSEN INDEHOLDER ET "@" TEGN OG TO DELE.
If UBound(EmailOpdeling) <> 1 Then
EmailGodkendt = "False"
Else
' -> DETTE CHECKER DEN SAMLEDE LÆNGDE AF E-MAIL ADRESSEN.
If Len(AfsenderEmail) < 6 Then
EmailGodkendt = "False"
End If
' -> DETTE CHECKER LÆNGDEN AF HVER DEL: FØRSTE DEL MERE END EN KARAKTER OG ANDEN DEL MERE END FIRE KARAKTERER.
If Len(EmailOpdeling(0)) < 1 Or Len(EmailOpdeling(1)) < 4 Then
EmailGodkendt = "False"
End If
' -> DETTE CHECKER, AT DER ER ET "." (PUNKTUM) I ANDEN DEL.
If InStr(EmailOpdeling(1), ".") <= 0 Then
EmailGodkendt = "False"
End If
' -> DETTE CHECKER, AT FØRSTE KARAKTER IKKE ER ET "." (PUNKTUM).
If Left(EmailOpdeling(0), 1) = "." Then
EmailGodkendt = "False"
End If
' -> DETTE CHECKER, AT SIDSTE OG NÆSTSIDSTE KARAKTER IKKE ER ET "." (PUNKTUM).
If Right(EmailOpdeling(1), 1) = "." Or Right(EmailOpdeling(1), 2) = "." Then
EmailGodkendt = "False"
End If
' -> DETTE CHECKER, AT DER ER MINDST TO KARAKTERER EFTER "." (PUNKTUMMET).
If Len(AfsenderEmail) - InStrRev(AfsenderEmail,".") < 2 Then
AfsenderEmailValid = "False"
End If
' -> DETTE CHECKER, AT DER IKKE ER MERE END FIRE KARAKTERER EFTER "." (PUNKTUMMET).
If Len(AfsenderEmail) - InStrRev(AfsenderEmail,".") > 4 Then
EmailGodkendt = "False"
End If
' -> DETTE CHECKER, OM DER ER TO "." (PUNKTUM) EFTER HINANDEN.
If InStr(AfsenderEmail, "..") > 0 Then
EmailGodkendt = "False"
End If
' -> DETTE CHECKER, OM DER ER TO "@" EFTER HINANDEN.
If InStr(AfsenderEmail, "@.") > 0 Then
EmailGodkendt = "False"
End If
' -> DETTE CHECKER, AT DER IKKE ER EN "_" I ANDEN DEL.
If InStr(EmailOpdeling(1), "_") > 0 Then
EmailGodkendt = "False"
End If
End If
' -> DETTE CHECKER HVER ENKELT KARAKTER. "LCase" KONVERTERER ALLE KARAKTERER TIL SMÅ BOGSTAVER. "Mid" RETURNERER KARAKTERERNE.
For iLoopCounter = 1 to Len(AfsenderEmail)
EmailKarakterer = Lcase(Mid(AfsenderEmail, iLoopCounter, 1))
' -> DETTE CHECKER, AT ALLE KARAKTERER ER TILLADTE.
If InStr(TilladteKarakterer, EmailKarakterer) = 0 And Not IsNumeric(EmailKarakterer) Then
EmailGodkendt = "False"
End If
Next
GodkendEmail = EmailGodkendt
End Function
Response.AddHeader "cache-control","private"
Response.AddHeader "pragma","no-cache"
Response.CacheControl = "no-cache"
Response.CacheControl = "private"
Response.Expires = -1
Response.ExpiresAbsolute = Now() -1
%>
<%
Response.Buffer = "True"
' -> DETTE ER VARIABLERNE TIL DATABASEN.
Dim myConn
Dim strSQL
' -> DSNLess FORBINDELSE TIL DATABASEN.
Set myConn = Server.CreateObject("ADODB.Connection")
myConn.Open "Driver={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("../../db/gb.mdb")
' -> DETTE GODKENDER E-MAIL ADRESSEN.
Function GodkendEmail(AfsenderEmail)
' -> DETTE ER VARIABLERNE TIL GODKENDELSEN.
Dim EmailGodkendt
Dim EmailOpdeling
Dim EmailKarakterer
Dim TilladteKarakterer
Dim iLoopCounter
EmailGodkendt = "True"
' -> DETTE ER DE TILLADTE KARAKTERER.
TilladteKarakterer = "abcdefghijklmnopqrstuvwxyz.-_@"
' -> DETTE OPDELER E-MAIL ADRESSEN I TO DELE VED "@" TEGNET.
EmailOpdeling = Split(AfsenderEmail, "@")
' -> DETTE CHECKER, AT E-MAIL ADRESSEN INDEHOLDER ET "@" TEGN OG TO DELE.
If UBound(EmailOpdeling) <> 1 Then
EmailGodkendt = "False"
Else
' -> DETTE CHECKER DEN SAMLEDE LÆNGDE AF E-MAIL ADRESSEN.
If Len(AfsenderEmail) < 6 Then
EmailGodkendt = "False"
End If
' -> DETTE CHECKER LÆNGDEN AF HVER DEL: FØRSTE DEL MERE END EN KARAKTER OG ANDEN DEL MERE END FIRE KARAKTERER.
If Len(EmailOpdeling(0)) < 1 Or Len(EmailOpdeling(1)) < 4 Then
EmailGodkendt = "False"
End If
' -> DETTE CHECKER, AT DER ER ET "." (PUNKTUM) I ANDEN DEL.
If InStr(EmailOpdeling(1), ".") <= 0 Then
EmailGodkendt = "False"
End If
' -> DETTE CHECKER, AT FØRSTE KARAKTER IKKE ER ET "." (PUNKTUM).
If Left(EmailOpdeling(0), 1) = "." Then
EmailGodkendt = "False"
End If
' -> DETTE CHECKER, AT SIDSTE OG NÆSTSIDSTE KARAKTER IKKE ER ET "." (PUNKTUM).
If Right(EmailOpdeling(1), 1) = "." Or Right(EmailOpdeling(1), 2) = "." Then
EmailGodkendt = "False"
End If
' -> DETTE CHECKER, AT DER ER MINDST TO KARAKTERER EFTER "." (PUNKTUMMET).
If Len(AfsenderEmail) - InStrRev(AfsenderEmail,".") < 2 Then
AfsenderEmailValid = "False"
End If
' -> DETTE CHECKER, AT DER IKKE ER MERE END FIRE KARAKTERER EFTER "." (PUNKTUMMET).
If Len(AfsenderEmail) - InStrRev(AfsenderEmail,".") > 4 Then
EmailGodkendt = "False"
End If
' -> DETTE CHECKER, OM DER ER TO "." (PUNKTUM) EFTER HINANDEN.
If InStr(AfsenderEmail, "..") > 0 Then
EmailGodkendt = "False"
End If
' -> DETTE CHECKER, OM DER ER TO "@" EFTER HINANDEN.
If InStr(AfsenderEmail, "@.") > 0 Then
EmailGodkendt = "False"
End If
' -> DETTE CHECKER, AT DER IKKE ER EN "_" I ANDEN DEL.
If InStr(EmailOpdeling(1), "_") > 0 Then
EmailGodkendt = "False"
End If
End If
' -> DETTE CHECKER HVER ENKELT KARAKTER. "LCase" KONVERTERER ALLE KARAKTERER TIL SMÅ BOGSTAVER. "Mid" RETURNERER KARAKTERERNE.
For iLoopCounter = 1 to Len(AfsenderEmail)
EmailKarakterer = Lcase(Mid(AfsenderEmail, iLoopCounter, 1))
' -> DETTE CHECKER, AT ALLE KARAKTERER ER TILLADTE.
If InStr(TilladteKarakterer, EmailKarakterer) = 0 And Not IsNumeric(EmailKarakterer) Then
EmailGodkendt = "False"
End If
Next
GodkendEmail = EmailGodkendt
End Function
Response.AddHeader "cache-control","private"
Response.AddHeader "pragma","no-cache"
Response.CacheControl = "no-cache"
Response.CacheControl = "private"
Response.Expires = -1
Response.ExpiresAbsolute = Now() -1
%>
<html>
<head>
<title>Gæstebog</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" type="text/css" href="guestbook.css">
<script type="text/JavaScript">
<!--
function MM_swapImgRestore() { //v3.0
var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_preloadImages() { //v3.0
var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
function MM_findObj(n, d) { //v4.01
var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function MM_swapImage() { //v3.0
var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
//-->
</script>
</head>
<body onLoad="if ('Navigator' == navigator.appName) document.forms[0].reset();" bgcolor="#FFFFFF" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" onLoad"MM_preloadImages('billeder/forside_over.jpg','billeder/galleri_over.jpg','billeder/os_over.jpg','billeder/gb_over.jpg','billeder/hund_over.jpg','billeder/kontakt_over.jpg')">
<table width="775" height="681" border="0" align="center" cellpadding="0" cellspacing="0" id="Tabel_01">
<tr>
<td colspan="2" rowspan="2">
<img src="billeder/m1.jpg" width="62" height="142" alt=""></td>
<td colspan="10">
<img src="billeder/m2.jpg" width="656" height="107" alt=""></td>
<td colspan="2">
<img src="billeder/m3.jpg" width="57" height="107" alt=""></td>
</tr>
<tr>
<td>
<a href="default.asp" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('forside','','billeder/forside_over.jpg',1)"><img src="billeder/forside.jpg" alt="Forside" name="forside" width="118" height="35" border="0"></a></td>
<td colspan="2"><a href="galleri.asp" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('galleri','','billeder/galleri_over.jpg',1)"><img src="billeder/galleri.jpg" alt="Galleri" name="galleri" width="110" height="35" border="0"></a></a></td>
<td><a href="os.asp" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('os','','billeder/os_over.jpg',1)"><img src="billeder/os.jpg" alt="Os" name="os" width="89" height="35" border="0"></a></a></td>
<td><a href="gb.asp" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('gb','','billeder/gb_over.jpg',1)"><img src="billeder/gb.jpg" alt="Gæstebog" name="gb" width="104" height="35" border="0"></a></a></td>
<td colspan="3"><a href="hund.asp" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Hund','','billeder/hund_over.jpg',1)"><img src="billeder/hund.jpg" alt="Hund (Mille)" name="Hund" width="102" height="35" border="0"></a></a></td>
<td colspan="2"><a href="kontakt.asp" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('kontakt','','billeder/kontakt_over.jpg',1)"><img src="billeder/kontakt.jpg" alt="Kontakt" name="kontakt" width="133" height="35" border="0"></a></a></td>
<td colspan="2" rowspan="3">
<img src="billeder/index_10.jpg" width="57" height="94" alt=""></td>
</tr>
<tr>
<td colspan="2" rowspan="2">
<img src="billeder/index_11_2.jpg" width="62" height="59" alt=""></td>
<td colspan="2">
<img src="billeder/wel1.jpg" width="143" height="23" alt=""></td>
<td colspan="4">
<img src="billeder/wel2.jpg" width="290" height="23" alt=""></td>
<td>
<img src="billeder/ln1.jpg" width="47" height="23" alt=""></td>
<td colspan="2">
<img src="billeder/ln2.jpg" width="159" height="23" alt=""></td>
<td rowspan="2">
<img src="billeder/index_16_2.jpg" width="17" height="59" alt=""></td>
</tr>
<tr>
<td colspan="9">
<img src="billeder/index_17_2.jpg" width="639" height="36" alt=""></td>
</tr>
<tr valign="top">
<td>
<img src="billeder/index_18_2.jpg" width="61" height="377" alt=""></td>
<td colspan="12" background="billeder/index_19_2.jpg"><table width="668" border="0" align="center">
<tr>
<td width="627"><%
Dim rsA
Set rsA = ObjConn.Execute("SELECT * FROM gb")
%>
<h2><%=rsA("headline")%></h2>
<%=rsA("gb")%></td>
</tr>
</table>
</p>
<table align="center" border="0" cellpadding="5" cellspacing="0" width="1%">
<tr>
<td align="left" valign="top" width="100%"><h1>Skriv i gæstebogen</h1>
<p>Skriv en hilsen i gæstebogen ved at udfylde nedenstående formular.</p>
<!-- FORMULAR START -->
<table align="center" border="0" cellpadding="10" cellspacing="0" width="350">
<tr>
<td align="left" valign="top" width="100%"><form action="hilsen_form.asp" method="post">
<%
' -> DETTE GODKENDER INDHOLDET FRA FORMULARFELTERNE.
GodkendFormular = Request.Form("GodkendFormular")
If GodkendFormular = "Ja" Then
Emne = Trim(Replace(Request.Form("Emne"), "'", "’"))
Hilsen = Trim(Replace(Request.Form("Hilsen"), "'", "’"))
AfsenderNavn = Trim(Replace(Request.Form("AfsenderNavn"), "'", "’"))
AfsenderEmail = Trim(Replace(Replace(Request.Form("AfsenderEmail"), "'", ""), "’", ""))
If Emne = "" Then
Fejl_Emne = "Ja"
End If
If Hilsen = "" Then
Fejl_Hilsen = "Ja"
End If
If AfsenderNavn = "" Then
Fejl_AfsenderNavn = "Ja"
End If
If GodkendEmail(AfsenderEmail) = "False" Then
Fejl_AfsenderEmail = "Ja"
End If
End If
If GodkendFormular = "" Or Fejl_Emne = "Ja" Or Fejl_Hilsen = "Ja" Or Fejl_AfsenderNavn = "Ja" Or Fejl_AfsenderEmail = "Ja" Then
%>
<p><span class="bold">Emne</span> <span class="error">
<%If Fejl_Emne = "Ja" Then Response.Write "Udfyld dette felt korrekt" End If%>
</span> <br clear="all">
<input maxlength="50" name="Emne" size="40" style="width: 260px" type="text" value="<%=Emne%>">
</p>
<script type="text/javascript">
<!--
function storeCaret(textEl)
{
if (textEl.createTextRange) textEl.caretPos = document.selection.createRange().duplicate();
}
function insertAtCaret(textEl, text)
{
if (textEl.createTextRange && textEl.caretPos)
{
var caretPos = textEl.caretPos;
caretPos.text = (caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? text + ' ' : text);
}
else
{
textEl.value = textEl.value + text;
}
textEl.focus();
}
//-->
</script>
<p><span class="bold">Hilsen</span></span> <span class="error">
<%If Fejl_Hilsen = "Ja" Then Response.Write "Udfyld dette felt korrekt" End If%>
</span> <br clear="all">
<textarea cols="38" ID="txtBody" name="Hilsen" onChange="storeCaret(this);" onClick="storeCaret(this);" onKeyUp="storeCaret(this);" onSelect="storeCaret(this);" rows="6" style="width: 260px" wrap="soft"><%=Hilsen%></textarea>
<!-- BEMÆRK: KODEN 'wrap="soft"' ER FOR TILPASNING TIL ÆLDRE NETSCAPE BROWSERE -->
<br clear="all">
<span class="small">Klik på et "Emoticon" for at føje det til din hilsen.</span><br clear="all">
<img alt=":-) Glad" title =":-) Glad"
border="0" height="16" hspace="2" onClick="insertAtCaret(document.getElementById('txtBody'),' :-) ');" src="images/emoticon_happy.gif" style="cursor: hand; cursor: pointer" width="16"> <img alt=":-D Meget glad" title =":-D Meget glad"
border="0" height="16" hspace="2" onClick="insertAtCaret(document.getElementById('txtBody'),' :-D ');" src="images/emoticon_very_happy.gif" style="cursor: hand; cursor: pointer" width="16"> <img alt=":-O Overrasket" title =":-O Overrasket"
border="0" height="16" hspace="2" onClick="insertAtCaret(document.getElementById('txtBody'),' :-O ');" src="images/emoticon_surprised.gif" style="cursor: hand; cursor: pointer" width="16"> <img alt=";-) Blinker med det ene øje" title=";-) Blinker med det ene øje"
border="0" height="16" hspace="2" onClick="insertAtCaret(document.getElementById('txtBody'),' ;-) ');" src="images/emoticon_winking.gif" style="cursor: hand; cursor: pointer" width="16"> <img alt=":-P Stikker tungen ud" title =":-P Stikker tungen ud"
border="0" height="16" hspace="2" onClick="insertAtCaret(document.getElementById('txtBody'),' :-P ');" src="images/emoticon_tongue_out.gif" style="cursor: hand; cursor: pointer" width="16"> <img alt=":-( Utilfreds" title =":-( Utilfreds"
border="0" height="16" hspace="2" onClick="insertAtCaret(document.getElementById('txtBody'),' :-( ');" src="images/emoticon_unhappy.gif" style="cursor: hand; cursor: pointer" width="16"> <img alt=":-S Vred" title =":-S Vred"
border="0" height="16" hspace="2" onClick="insertAtCaret(document.getElementById('txtBody'),' :-S ');" src="images/emoticon_angry.gif" style="cursor: hand; cursor: pointer" width="16"> </p>
<!-- BEMÆRK: KODEN 'style="cursor: pointer"' ÆNDRER MUSEPILEN TIL EN HÅND I 'Netscape 6+', 'IE6/Win' OG 'IE5.x/Mac' -->
<!-- BEMÆRK: KODEN 'style="cursor: hand"' ÆNDRER MUSEPILEN TIL EN HÅND I 'IE5.x/Win' -->
<p><span class="bold">Afsender</span> <span class="error">
<%If Fejl_AfsenderNavn = "Ja" Then Response.Write "Udfyld dette felt korrekt" End If%>
</span> <br clear="all">
<input maxlength="50" name="AfsenderNavn" size="40" style="width: 260px" type="text" value="<%=AfsenderNavn%>">
</p>
<p><span class="bold">E-mail</span> <span class="error">
<%If Fejl_AfsenderEmail = "Ja" Then Response.Write "Udfyld dette felt korrekt" End If%>
</span> <br clear="all">
<input maxlength="50" name="AfsenderEmail" size="40" style="width: 260px" type="text" value="<%=AfsenderEmail%>">
</p>
<br clear="all">
<table>
<tr>
<td><input name="submit" type="submit" class="button" onMouseOver="this.className='buttonHover'" onMouseOut="this.className='button'" value="SEND"></td>
<td><input name="reset" type="reset" class="button" onClick="GoToURL();" onMouseOver="this.className='buttonHover'" onMouseOut="this.className='button'" value="SLET ALT"></td>
</tr>
</table>
<!-- BEMÆRK: KNAPPERNE ER PLACEREDE I EN TABEL FOR FULD UDNYTTELSE AF 'MouseOver' EGENSKABERNE I OPERA 7 BROWSEREN -->
<input name="GodkendFormular" type="hidden" value="Ja">
</form></td>
</tr>
</table>
<!-- FORMULAR SLUT -->
</td>
</tr>
</table></td>
<td>
<img src="billeder/index_20_2.jpg" width="29" height="377" alt=""></td>
</tr>
<tr>
<td colspan="2" rowspan="3">
<img src="billeder/index_21_2.jpg" width="62" height="102" alt=""></td>
<td colspan="10">
<img src="billeder/index_22_2.jpg" width="656" height="17" alt=""></td>
<td colspan="2" rowspan="3">
<img src="billeder/index_23_2.jpg" width="57" height="102" alt=""></td>
</tr>
<tr>
<td colspan="10">
<img src="billeder/dn_2.jpg" width="656" height="20" alt=""></td>
</tr>
<tr>
<td colspan="10">
<img src="billeder/index_25_2.jpg" width="656" height="65" alt=""></td>
</tr>
<tr>
<td>
<img src="billeder/spacer.gif" width="61" height="1" alt=""></td>
<td>
<img src="billeder/spacer.gif" width="1" height="1" alt=""></td>
<td>
<img src="billeder/spacer.gif" width="118" height="1" alt=""></td>
<td>
<img src="billeder/spacer.gif" width="25" height="1" alt=""></td>
<td>
<img src="billeder/spacer.gif" width="85" height="1" alt=""></td>
<td>
<img src="billeder/spacer.gif" width="89" height="1" alt=""></td>
<td>
<img src="billeder/spacer.gif" width="104" height="1" alt=""></td>
<td>
<img src="billeder/spacer.gif" width="12" height="1" alt=""></td>
<td>
<img src="billeder/spacer.gif" width="47" height="1" alt=""></td>
<td>
<img src="billeder/spacer.gif" width="43" height="1" alt=""></td>
<td>
<img src="billeder/spacer.gif" width="116" height="1" alt=""></td>
<td>
<img src="billeder/spacer.gif" width="17" height="1" alt=""></td>
<td>
<img src="billeder/spacer.gif" width="28" height="1" alt=""></td>
<td>
<img src="billeder/spacer.gif" width="29" height="1" alt=""></td>
</tr>
</table>
</body>
</html>
<%
Call CloseDatabase
%>
<%
Else
strSQL = "SELECT * FROM Hilsener"
Set rs = Server.CreateObject("ADODB.recordset")
rs.Open strSQL, myConn, 1, 3
' -> DETTE ER VARIABLERNE FRA FORMULARFELTERNE.
Dim Emne
Dim Hilsen
Dim AfsenderNavn
Dim AfsenderEmail
Dim AfsenderDato
rs.AddNew
rs("Emne") = Trim(Replace(Request.Form("Emne"), "'", "’"))
rs("Hilsen") = Trim(Replace(Request.Form("Hilsen"), "'", "’"))
rs("AfsenderNavn") = Trim(Replace(Request.Form("AfsenderNavn"), "'", "’"))
rs("AfsenderEmail") = Trim(Replace(Replace(Request.Form("AfsenderEmail"), "'", ""), "’", ""))
rs("AfsenderDato") = Now()
rs.Update
rs.Close
Set rs = Nothing
myConn.Close
Set myConn = Nothing
Response.Redirect("hilsen_tak.htm")
End If
%>
Her nedenunder kan du se gæstebogen på en blank side uden mit design. (Og denne virker).
<%
Response.Buffer = "True"
' -> DETTE ER VARIABLERNE TIL DATABASEN.
Dim myConn
Dim strSQL
' -> DSNLess FORBINDELSE TIL DATABASEN.
Set myConn = Server.CreateObject("ADODB.Connection")
myConn.Open "Driver={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("../../db/gb.mdb")
' -> DETTE GODKENDER E-MAIL ADRESSEN.
Function GodkendEmail(AfsenderEmail)
' -> DETTE ER VARIABLERNE TIL GODKENDELSEN.
Dim EmailGodkendt
Dim EmailOpdeling
Dim EmailKarakterer
Dim TilladteKarakterer
Dim iLoopCounter
EmailGodkendt = "True"
' -> DETTE ER DE TILLADTE KARAKTERER.
TilladteKarakterer = "abcdefghijklmnopqrstuvwxyz.-_@"
' -> DETTE OPDELER E-MAIL ADRESSEN I TO DELE VED "@" TEGNET.
EmailOpdeling = Split(AfsenderEmail, "@")
' -> DETTE CHECKER, AT E-MAIL ADRESSEN INDEHOLDER ET "@" TEGN OG TO DELE.
If UBound(EmailOpdeling) <> 1 Then
EmailGodkendt = "False"
Else
' -> DETTE CHECKER DEN SAMLEDE LÆNGDE AF E-MAIL ADRESSEN.
If Len(AfsenderEmail) < 6 Then
EmailGodkendt = "False"
End If
' -> DETTE CHECKER LÆNGDEN AF HVER DEL: FØRSTE DEL MERE END EN KARAKTER OG ANDEN DEL MERE END FIRE KARAKTERER.
If Len(EmailOpdeling(0)) < 1 Or Len(EmailOpdeling(1)) < 4 Then
EmailGodkendt = "False"
End If
' -> DETTE CHECKER, AT DER ER ET "." (PUNKTUM) I ANDEN DEL.
If InStr(EmailOpdeling(1), ".") <= 0 Then
EmailGodkendt = "False"
End If
' -> DETTE CHECKER, AT FØRSTE KARAKTER IKKE ER ET "." (PUNKTUM).
If Left(EmailOpdeling(0), 1) = "." Then
EmailGodkendt = "False"
End If
' -> DETTE CHECKER, AT SIDSTE OG NÆSTSIDSTE KARAKTER IKKE ER ET "." (PUNKTUM).
If Right(EmailOpdeling(1), 1) = "." Or Right(EmailOpdeling(1), 2) = "." Then
EmailGodkendt = "False"
End If
' -> DETTE CHECKER, AT DER ER MINDST TO KARAKTERER EFTER "." (PUNKTUMMET).
If Len(AfsenderEmail) - InStrRev(AfsenderEmail,".") < 2 Then
AfsenderEmailValid = "False"
End If
' -> DETTE CHECKER, AT DER IKKE ER MERE END FIRE KARAKTERER EFTER "." (PUNKTUMMET).
If Len(AfsenderEmail) - InStrRev(AfsenderEmail,".") > 4 Then
EmailGodkendt = "False"
End If
' -> DETTE CHECKER, OM DER ER TO "." (PUNKTUM) EFTER HINANDEN.
If InStr(AfsenderEmail, "..") > 0 Then
EmailGodkendt = "False"
End If
' -> DETTE CHECKER, OM DER ER TO "@" EFTER HINANDEN.
If InStr(AfsenderEmail, "@.") > 0 Then
EmailGodkendt = "False"
End If
' -> DETTE CHECKER, AT DER IKKE ER EN "_" I ANDEN DEL.
If InStr(EmailOpdeling(1), "_") > 0 Then
EmailGodkendt = "False"
End If
End If
' -> DETTE CHECKER HVER ENKELT KARAKTER. "LCase" KONVERTERER ALLE KARAKTERER TIL SMÅ BOGSTAVER. "Mid" RETURNERER KARAKTERERNE.
For iLoopCounter = 1 to Len(AfsenderEmail)
EmailKarakterer = Lcase(Mid(AfsenderEmail, iLoopCounter, 1))
' -> DETTE CHECKER, AT ALLE KARAKTERER ER TILLADTE.
If InStr(TilladteKarakterer, EmailKarakterer) = 0 And Not IsNumeric(EmailKarakterer) Then
EmailGodkendt = "False"
End If
Next
GodkendEmail = EmailGodkendt
End Function
Response.AddHeader "cache-control","private"
Response.AddHeader "pragma","no-cache"
Response.CacheControl = "no-cache"
Response.CacheControl = "private"
Response.Expires = -1
Response.ExpiresAbsolute = Now() -1
%><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Gæstebog med Smil</title>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1">
<meta http-equiv="expires" content="-1">
<meta http-equiv="pragma" content="no-cache">
<meta name="author" content="Gæstebog med Smil">
<meta name="description" content="Gæstebog med Smil">
<meta name="keywords" content="Gæstebog med Smil">
<link rel="stylesheet" type="text/css" href="guestbook.css">
<script type="text/javascript">
<!--
function GoToURL()
{
window.location="hilsen_form.asp";
}
//-->
</script>
</head>
<body onLoad="if ('Navigator' == navigator.appName) document.forms[0].reset();">
<!-- INDHOLD START -->
<table align="center" border="0" cellpadding="5" cellspacing="0" width="47%">
<tr>
<td align="left" valign="top" width="100%">
<h1>Skriv i gæstebogen</h1>
<p>Skriv en hilsen i gæstebogen ved at udfylde nedenstående formular.</p>
<!-- FORMULAR START -->
<table align="center" border="0" cellpadding="10" cellspacing="0" width="350">
<tr>
<td align="left" valign="top" width="100%">
<form action="hilsen_form.asp" method="post">
<%
' -> DETTE GODKENDER INDHOLDET FRA FORMULARFELTERNE.
GodkendFormular = Request.Form("GodkendFormular")
If GodkendFormular = "Ja" Then
Emne = Trim(Replace(Request.Form("Emne"), "'", "’"))
Hilsen = Trim(Replace(Request.Form("Hilsen"), "'", "’"))
AfsenderNavn = Trim(Replace(Request.Form("AfsenderNavn"), "'", "’"))
AfsenderEmail = Trim(Replace(Replace(Request.Form("AfsenderEmail"), "'", ""), "’", ""))
If Emne = "" Then
Fejl_Emne = "Ja"
End If
If Hilsen = "" Then
Fejl_Hilsen = "Ja"
End If
If AfsenderNavn = "" Then
Fejl_AfsenderNavn = "Ja"
End If
If GodkendEmail(AfsenderEmail) = "False" Then
Fejl_AfsenderEmail = "Ja"
End If
End If
If GodkendFormular = "" Or Fejl_Emne = "Ja" Or Fejl_Hilsen = "Ja" Or Fejl_AfsenderNavn = "Ja" Or Fejl_AfsenderEmail = "Ja" Then
%>
<p><span class="bold">Emne</span> <span class="error"><%If Fejl_Emne = "Ja" Then Response.Write "Udfyld dette felt korrekt" End If%></span>
<br clear="all"><input maxlength="50" name="Emne" size="40" style="width: 260px" type="text" value="<%=Emne%>"></p>
<script type="text/javascript">
<!--
function storeCaret(textEl)
{
if (textEl.createTextRange) textEl.caretPos = document.selection.createRange().duplicate();
}
function insertAtCaret(textEl, text)
{
if (textEl.createTextRange && textEl.caretPos)
{
var caretPos = textEl.caretPos;
caretPos.text = (caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? text + ' ' : text);
}
else
{
textEl.value = textEl.value + text;
}
textEl.focus();
}
//-->
</script>
<p><span class="bold">Hilsen</span></span> <span class="error"><%If Fejl_Hilsen = "Ja" Then Response.Write "Udfyld dette felt korrekt" End If%></span>
<br clear="all"><textarea cols="38" ID="txtBody" name="Hilsen" onChange="storeCaret(this);" onClick="storeCaret(this);" onKeyUp="storeCaret(this);" onSelect="storeCaret(this);" rows="6" style="width: 260px" wrap="soft"><%=Hilsen%></textarea>
<!-- BEMÆRK: KODEN 'wrap="soft"' ER FOR TILPASNING TIL ÆLDRE NETSCAPE BROWSERE -->
<br clear="all"><span class="small">Klik på et "Emoticon" for at føje det til din hilsen.</span><br clear="all">
<img alt=":-) Glad" title =":-) Glad"
border="0" height="16" hspace="2" onClick="insertAtCaret(document.getElementById('txtBody'),' :-) ');" src="images/emoticon_happy.gif" style="cursor: hand; cursor: pointer" width="16">
<img alt=":-D Meget glad" title =":-D Meget glad"
border="0" height="16" hspace="2" onClick="insertAtCaret(document.getElementById('txtBody'),' :-D ');" src="images/emoticon_very_happy.gif" style="cursor: hand; cursor: pointer" width="16">
<img alt=":-O Overrasket" title =":-O Overrasket"
border="0" height="16" hspace="2" onClick="insertAtCaret(document.getElementById('txtBody'),' :-O ');" src="images/emoticon_surprised.gif" style="cursor: hand; cursor: pointer" width="16">
<img alt=";-) Blinker med det ene øje" title=";-) Blinker med det ene øje"
border="0" height="16" hspace="2" onClick="insertAtCaret(document.getElementById('txtBody'),' ;-) ');" src="images/emoticon_winking.gif" style="cursor: hand; cursor: pointer" width="16">
<img alt=":-P Stikker tungen ud" title =":-P Stikker tungen ud"
border="0" height="16" hspace="2" onClick="insertAtCaret(document.getElementById('txtBody'),' :-P ');" src="images/emoticon_tongue_out.gif" style="cursor: hand; cursor: pointer" width="16">
<img alt=":-( Utilfreds" title =":-( Utilfreds"
border="0" height="16" hspace="2" onClick="insertAtCaret(document.getElementById('txtBody'),' :-( ');" src="images/emoticon_unhappy.gif" style="cursor: hand; cursor: pointer" width="16">
<img alt=":-S Vred" title =":-S Vred"
border="0" height="16" hspace="2" onClick="insertAtCaret(document.getElementById('txtBody'),' :-S ');" src="images/emoticon_angry.gif" style="cursor: hand; cursor: pointer" width="16">
</p>
<!-- BEMÆRK: KODEN 'style="cursor: pointer"' ÆNDRER MUSEPILEN TIL EN HÅND I 'Netscape 6+', 'IE6/Win' OG 'IE5.x/Mac' -->
<!-- BEMÆRK: KODEN 'style="cursor: hand"' ÆNDRER MUSEPILEN TIL EN HÅND I 'IE5.x/Win' -->
<p><span class="bold">Afsender</span> <span class="error"><%If Fejl_AfsenderNavn = "Ja" Then Response.Write "Udfyld dette felt korrekt" End If%></span>
<br clear="all"><input maxlength="50" name="AfsenderNavn" size="40" style="width: 260px" type="text" value="<%=AfsenderNavn%>"></p>
<p><span class="bold">E-mail</span> <span class="error"><%If Fejl_AfsenderEmail = "Ja" Then Response.Write "Udfyld dette felt korrekt" End If%></span>
<br clear="all"><input maxlength="50" name="AfsenderEmail" size="40" style="width: 260px" type="text" value="<%=AfsenderEmail%>"></p>
<br clear="all">
<table>
<tr>
<td><input class="button" onMouseOut="this.className='button'" onMouseOver="this.className='buttonHover'" type="submit" value="SEND"></td>
<td><input class="button" onClick="GoToURL();" onMouseOut="this.className='button'" onMouseOver="this.className='buttonHover'" type="reset" value="SLET ALT"></td>
</tr>
</table>
<!-- BEMÆRK: KNAPPERNE ER PLACEREDE I EN TABEL FOR FULD UDNYTTELSE AF 'MouseOver' EGENSKABERNE I OPERA 7 BROWSEREN -->
<input name="GodkendFormular" type="hidden" value="Ja">
</form>
</td>
</tr>
</table>
<!-- FORMULAR SLUT -->
</td>
</tr>
</table>
<!-- INDHOLD SLUT -->
</body>
<head>
<meta http-equiv="expires" content="-1">
<meta http-equiv="pragma" content="no-cache">
</head>
</html>
<%
Else
strSQL = "SELECT * FROM Hilsener"
Set rs = Server.CreateObject("ADODB.recordset")
rs.Open strSQL, myConn, 1, 3
' -> DETTE ER VARIABLERNE FRA FORMULARFELTERNE.
Dim Emne
Dim Hilsen
Dim AfsenderNavn
Dim AfsenderEmail
Dim AfsenderDato
rs.AddNew
rs("Emne") = Trim(Replace(Request.Form("Emne"), "'", "’"))
rs("Hilsen") = Trim(Replace(Request.Form("Hilsen"), "'", "’"))
rs("AfsenderNavn") = Trim(Replace(Request.Form("AfsenderNavn"), "'", "’"))
rs("AfsenderEmail") = Trim(Replace(Replace(Request.Form("AfsenderEmail"), "'", ""), "’", ""))
rs("AfsenderDato") = Now()
rs.Update
rs.Close
Set rs = Nothing
myConn.Close
Set myConn = Nothing
Response.Redirect("hilsen_tak.htm")
End If
%>