Click here to Skip to main content
14,176,439 members
Click here to Skip to main content
Add your own
alternative version


24 bookmarked
Posted 21 Jan 2004

A simple feedback form in ASP 2

, 21 Jan 2004
Rate this:
Please Sign up or sign in to vote.
A simple ASP feedback form with a little extra features like client's IP, browser info etc.

How it looks!



This is the second version of the other feedback form I submitted. I am resubmitting it because the bugs in the older version and the updating procedure takes a hell lot of time, and also it should be noted that I have become modest now (see article's title!).

This is my second contribution to CodeProject so don't be angry with me if you think that this code is below you! I have been working on this during my school vacations (took me 32 minutes for building and debugging this on Jan 12, 2004). This is a simple feedback form which allows your website's users to send you feedback directly to your email ID. And to prevent spamming of your inbox, it has been configured so that each user can give feedback to you only once in a week (cookies)! It even mails their PC info (IP, Browser Info), the time it was posted, and the number of times you have received feedback! The form disables right click on the page without any prompt, and also you can bookmark CodeProject and set it as your homepage! All this is in the source files!


If you have basic knowledge about cookies and CDONTS, then this tutorial is as easy as a pie! Even if you don't know anything about cookies and CDONTS, you can just download the companion ZIP containing the source files, change the email address to your own in a text editor like Notepad, and upload it into your web server which supports ASP and CDONTS, to watch the magic!

The code

Here's the code for checking whether the user has already given you feedback in the past week:

strfeed = Request.Cookies("Feed")("Yes")
IF (Len(strfeed) > 0) then
    Response.Write "<font color=red><b>You have already" _
             " given us feedback! You can give it again only " _
             "after a week!</b></font>"
    Response.Redirect "Index.asp"
End IF

Here's the code for requesting the form content:

strnam = Trim(Request.Form("name"))
stremail = Trim(request.form("mail")) 
strcom = Trim(request.form("com")) 
strcom = Trim(request.form("sug"))

In the above code, the form elements are:

  1. name - The name of the user (textbox)
  2. mail - The Email ID of the user (textbox)
  3. com - Comments from the user (textarea)
  4. sug - Suggestions from the user (textarea)

Here's the code for checking if the form fields are filled or not, and submitting the form if yes:

if (strnam <> "" and stremail <> "" and strcom <> "" _
           and strsug <> "")then
    dim newmail, strfeed, ipadd, brow, now, msgbody, date, _
                 strnam, stremail, strcom, strsug
    num = application(num)
    ipadd = Request.ServerVariables("REMOTE_ADDR")
    brow = Request.ServerVariables("HTTP_USER_AGENT")
    date = time

    msgbody = "Suggestions: " & strsug & "Comments: " & strcom & _
              vbcrlf & "PC info:" & "IP:" & ipadd & "Browser: " & brow & _
              "Time:" & date & "Hits:" & num &"times!")
    Set Newmail = server.CreateObject ("cdonts.newmail")
    Newmail.From = stremail
    Newmail.To = ""
    Newmail.Subject = "Feedback From:" & strnam
    Newmail.Body = msgbody
    Set Newmail = Nothing

Analysis: This code will retrieve the form fields and mail them with the IP address, browser info and time signed, to the email address ''! Before this code works, you need to add the following code declarations so as to enable counting the number of hits:

Dim Num
Num = Request.Servervariables("SCRIPT_NAME")  
IF isEmpty(Application(Num)) Then 
Application(Num) = Application(Num)+1 

Here's the code for setting a cookie that expires after a week:

Response.Cookies("Feed")("Yes") = "yes"
Response.Cookies("Feed").Expires = DateAdd("d",7,Now()) 
Response.Redirect "index.asp"

Analysis: Here we are setting the value yes to the cookie 'Feed' which when checked by the first bit of code will redirect the page to 'index.asp' if the value is greater than 0, i.e. (Len(strfeed)>0). After setting the cookies, the page will automatically be redirected towards 'index.asp'.

As a bonus, I am including the code for disabling right-click on an ASP page without even a prompt! Add this code into your body section! Here's the code:

<script language="JavaScript">
   var message="";
   function clickIE() {if (document.all) {(message);return false;}}
   function clickNS(e){
     if (document.layers||(document.getElementById&&!document.all)) {
       if (e.which==2||e.which==3) {(message);return false;}}}
     if (document.layers){
     document.oncontextmenu=new Function("return false")

Go here for an ever lasting sample!

Note: Change the email ( address to the address where you prefer to receive the feedback, in a text editor like Notepad, and upload it into your web server which supports ASP and CDONTS, to watch the magic!

Please rate it if you do like it! Comments and suggestions are also welcome!


This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


About the Author

Ipog Thomas
United States United States
Ageing considerably (16) and towering at 6 foot 2, I happen to be the one of the most eligible nerds around (for ro***ce). While I posses a sarcastic sense of humor, I tend to be a little too pessimistic sometimes.
When I'm not studyin', I strap on my back-pack and go in search of woman-eating tigers.My accomplishments include skiing down Mt. Everest, hunting (as mentioned earlier), swimming naked across the english channel during winter, writing Eminem's lyrics,advising Bush on taking critisim.
I also take pride in hac***g.

You may also be interested in...

Comments and Discussions

QuestionI am getting internal server error on button click Pin
punithws29-Aug-11 17:58
memberpunithws29-Aug-11 17:58 
GeneralLots of little issues with code Pin
FBPettis13-Oct-06 9:44
memberFBPettis13-Oct-06 9:44 
GeneralRe: Lots of little issues with code Pin
asfahaan25-May-07 7:17
memberasfahaan25-May-07 7:17 
GeneralFunctions declared as variables Pin
FBPettis6-Oct-06 5:26
memberFBPettis6-Oct-06 5:26 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Cookies | Terms of Use | Mobile
Web02 | 2.8.190525.1 | Last Updated 22 Jan 2004
Article Copyright 2004 by Ipog Thomas
Everything else Copyright © CodeProject, 1999-2019
Layout: fixed | fluid