Tilføje email
Jeg har en formular hvor jeg gerne vil have at feltet email bliver tilføjet til en database hvis brugeren vælger ja....Her er koden:
<% @LANGUAGE = VBScript %>
<% Option Explicit %>
<html>
<head>
<title>vipiil - send salgsopstilling</title>
</head>
<body bgcolor=#ffffff>
<%
Dim strName, strEmail, strQuery, strAdresse, strBy, strTlf, strTlfArbejde, strSagsnr, strSalgsopstilling, strArchive
strName = Trim(Request.Form(\"ClientName\"))
strAdresse = Trim(Request.Form(\"ClientAdresse\"))
strBy = Trim(Request.Form(\"ClientBy\"))
strTlf = Trim(Request.Form(\"ClientTlf\"))
strTlfArbejde = Trim(Request.Form(\"ClientTlfArbejde\"))
strEmail = Trim(Request.Form(\"ClientEmail\"))
strQuery = Trim(Request.Form(\"ClientQry\"))
strSagsnr = Trim(Request.Form(\"ClientSagsnr\"))
strSalgsopstilling = Trim(Request.Form(\"ClientSalgsopstilling\"))
strArchive = Trim(Request.Form(\"ClientArchive\"))
If (strName <> \"\") Then
Dim objMail, aRecipients
if strArchive = \"1\" then
set conn=Server.CreateObject(\"ADODB.Connection\")
conn.Provider=\"Microsoft.Jet.OLEDB.4.0\"
conn.Open(Server.Mappath(\"SpawnedMailer.mdb\"))
set rsMail = Server.CreateObject(\"ADODB.recordset\")
rsMail.Open \"SELECT * FROM MailingList WHERE MailingAddy=\'\" & strEmail & \"\'\", conn
If not rsMail.EOF Then
If rsMail(\"MailingAddy\") = strEmail Then
End if
Else
ArchiveSQL = \"INSERT into MailingList (MailingAddy) VALUES (\'\" & strEmail & \"\');\"
conn.Execute ArchiveSQL
end if
rsMail.close
conn.close
end if
Set objMail = Server.CreateObject(\"CDONTS.NewMail\")
objMail.From = \"ssm@minolta.dk\"
objMail.To = \"ssm@minolta.dk\"
objMail.Subject = \"ddd! \"
objMail.Body = \"!!!! \"
objMail.Send
Response.Write \"Tak for din bestilling ! \" & strName
Set objMail = Nothing
Else
%>
<FORM ACTION=\"<%=Request.ServerVariables(\"SCRIPT_NAME\")%>\" METHOD=POST>
<div align=\"center\">
<center>
<TABLE BORDER=0 width=\"550\">
</center>
<center>
</center>
<center>
<tr><td width=\"91\">Navn:</td><td width=\"11\"><img border=\"0\" src=\"../images/stjerne.gif\" width=\"10\" height=\"10\"></td><td width=\"428\" colspan=\"4\"><INPUT NAME=\"ClientName\" VALUE=\"\" SIZE=57 tabindex=\"1\"></td></tr>
<tr><td width=\"91\">Adresse:</td><td width=\"11\"><img border=\"0\" src=\"../images/stjerne.gif\" width=\"10\" height=\"10\"></td><td width=\"428\" colspan=\"4\"><input type=\"text\" name=\"ClientAdresse\" size=\"57\" tabindex=\"2\"></td></tr>
<tr><td width=\"91\">Postnr. og by:</td><td width=\"11\"><img border=\"0\" src=\"../images/stjerne.gif\" width=\"10\" height=\"10\"></td><td width=\"428\" colspan=\"4\"><input type=\"text\" name=\"ClientBy\" size=\"57\" tabindex=\"3\"></td></tr>
<tr>
<td width=\"91\">Tlf:</td><td width=\"11\"></td><td width=\"428\" colspan=\"4\"><input type=\"text\" name=\"ClientTlf\" size=\"18\" tabindex=\"4\">Tlf (arbejde/mobil):<input type=\"text\" name=\"ClientTlfArbejde\" size=\"20\" tabindex=\"5\"></td>
</tr>
<tr><td width=\"91\">e-mail adresse</td><td width=\"11\"></td><td width=\"428\" colspan=\"4\"><INPUT NAME=\"ClientEmail\" SIZE=57 tabindex=\"6\"></td></tr>
<tr><td width=\"91\"></td><td width=\"11\"></td>
</center>
<td width=\"428\" colspan=\"4\">
<p align=\"left\">Få automatisk opdatering og nyhedsbrev
tilsendt Ja<input type=\"radio\" value=\"1\" checked name=\"ClientArchive\">
Nej<input type=\"radio\" name=\"ClientArchive\" value=\"0\"></td></tr>
<center>
<tr><td width=\"91\"></td><td width=\"11\"></td><td width=\"94\"></td><td width=\"90\"></td><td width=\"16\"></td><td width=\"220\"></td></tr>
<tr><td width=\"91\"></td><td width=\"11\"></td><td width=\"94\"><INPUT TYPE=SUBMIT VALUE=\"Send\" tabindex=\"7\"></td><td width=\"90\"></td><td width=\"16\"><img border=\"0\" src=\"../images/stjerne.gif\" width=\"10\" height=\"10\" align=\"right\"></td><td width=\"220\">skal
udfyldes</td></tr>
</TABLE>
</center>
</div>
</FORM>
<% End If %>
</body>
</html>
Men her får jeg en fejl:
Microsoft VBScript runtime error \'800a01f4\'
Variable is undefined: \'conn\'
/mail/spaw1.asp, line 28
Jeg vil gerne have hjælp til at få den til at virke samt til at hvis strEmail er tomt så skal den ikke gøre noget.