ASP Is Fun

Learning ASP
Free Course
Basics
Functions
SQL Commands
Sample Code

Servers / Setup
Host Reviews
Server Setup
Error Tips

Contract ASP
Development

Intro to ASP



 
Irish Romance


ASP Contact Box Code
Step 2 - Contact Form Processing



You never want to reveal your email address to spammers! By having a contact box, you get in information safely from your visitors. Be sure you start with Step 1 - Setting Up the Contact Form

Here is the code you put into contact_p.asp, your processing page.

Email = Request("email")
Username = Request("username")
Topic = Request("topic")
Tip = Request("tip")
Tip = trim(Tip)

if len(Tip) = 0 then Response.Redirect("contact_thanks.asp")

if InStr(Tip, "<") > 0 then response.redirect("contacterror.asp")
if InStr(Tip, "[") > 0 then response.redirect("contacterror.asp")
if InStr(Tip, "Subject:") > 0 then response.redirect("contacterror.asp")
if InStr(Tip, "@aspisfun.com") > 0 then response.redirect("contacterror.asp")

Body = "Email: " & Email & vbCrLf
Body = Body & "TIP: " & vbCrLf & tip & vbrLf

Set objErrMail= Server.CreateObject("CDO.Message")
 With objErrMail
	  .From = "NOTE NOTE PUT YOUR EMAIL ADDRESS HERE"
	  .To =  "NOTE NOTE PUT YOUR EMAIL ADDRESS HERE"
	  .Subject = "ASPIsFun.com Query : " & Topic
	  .TextBody = Body
	  .Send
 End With
Set objErrMail = Nothing

Response.Redirect("contact_thanks.asp")

What I'm doing here is filtering out spam-bots that try to send you URLs or UBB code. I filter out spam-bots that try to "insert" an actual spammy email address, because usually they have the Subject: line in them. Also, anybody that tries to put MY email address (i.e. @aspisfun.com addresses) into the message is obviously a spammer. They're trying to fake a message going out from me.

Once this code is set in contact_p.asp, you only need two other pages created. One is contact_thanks.asp which is a simple HTML page that says "thank you for writing". That can be set up any way you wish. The other is contacterror.asp - and this just says "there was an error with your input". So neither of those pages require special code.

Enjoy!

ASP Free Sample Code Directory


ASP Main Page | ASP Ebooks | Free ASP Course | Contact Lisa
All content copyright © 2008 Minerva WebWorks LLC. All rights reserved.



Free Newsletter!

Ebooks
Intro to ASP
ASP SQL DB
Members
Shopping


Introduction to ASP

Romance Tips
Irish Romance
Italian Romance
French Romance

ASP Poll
How do you handle 500 errors?
I don't
Page does nothing
Displays error
Emails error