Continued from page 1
. .
.The form handling script. ..
.<% Dim nName, eEmail, AllOk, bText, Mailer AllOk = True
' We use AllOk to see whether it is Ok to proceed further or not. If AllOk contains "False," we do not proceed. The use of AllOk here may seem needless here, but if there are many fields, it comes handy.
nName = Trim(Request.Form("name"))
eEmail = Trim(Request.Form("email))
If Len(eEmail) = 0 then Response.Write "You cannot submit details without submitting your email. Please press
BACK button of your browser and try again."
AllOk = False
End If
If AllOk = True then
bText = "The visitor to
web site has entered
following details:" & Chr(13) & Chr(10) & Chr(13) & Chr(10)
' We use
combination of Chr(13) and Chr(10) to insert
line breaks.
bText = bText & "Visitor's Name: " & nName & Chr(13) & Chr(10) bText = bText & "Visitor's Email: " & eEmail
' This section uses SMTP ' Sending
email to
webmaster.
Set Mailer = Server.CreateObject("SMTPsvg.Mailer) Mailer.FromAddress = eEmail Mailer.FromName = nName Mailer.AddRecipient "Webmaster", "webmaster@yourdomain.com" Mailer.RemoteHost = "mail.yourdomain.com" Mailer.Subject = "Form submitted at your web site!" Mailer.BodyText = bText
If Mailer.SendMail then Response.Redirect "thankyou.html" Else Response.Redirect "error.html" End If
Set Mailer = nothing
' This section uses CDONTS ' Sending
email to
webmaster.
Set Mailer = Server.CreateObject("CDONTS.NewMail") Mailer.From = eEmail Mailer.To = "webmaster@yourdomain.com" Mailer.Subject = Form submitted at your web site!" Mailer.Body = bText
If Mailer.Send then Response.Redirect "thankyou.html" Else Response.Redirect "error.html" End If
Set Mailer = nothing
End If
.%>
I have demonstrated both CDONTS and SMTP, but you have to use only one. You'll have to ask your web host what to use.
As usual, if you have a doubt, you can write to me at amrit@bytesworth.com.
All
best.

Amrit Hallan is a freelance web designer. For all web site development and web promotion needs, you can get in touch with him at http://www.bytesworth.com. For more such articles, visit http://www.bytesworth.com/articles and http://www.bytesworth.com/learn You can subscribe to his newsletter [BYTESWORTH REACHOUT] on Web Designing Tips & Tricks by sending a blank email at bytesworth-subscribe@topica.com