Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4

Thread: Contact form

  1. #1
    Regular Coder
    Join Date
    Jul 2004
    Posts
    173
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Contact form

    Hi people,

    Just a quick cry for help really as im getting a little frustrated with dead ends!

    Ok so i just need a simple web form which submits the data to an email address using ASP.

    Ive tried a few self made scripts from google and generators etc but i cant get it to work succesfully.

    I use 1and1.co.uk for a host and they say they support ASPMAIL component and they supply this information
    Incoming server (IMAP) imap.1and1.co.uk
    Incoming server (POP) pop.1and1.co.uk
    Outgoing server (SMTP) auth.smtp.1and1.co.uk
    I literally need a form saying

    Name

    Address

    and some fields with tick boxes

    which then submits to adam@eastcornwallwheelstowork.co.uk

    can anyone help? kinda on a timescale here and i would very much appriciate it.

    Thanks in advance
    Web and Business Development from Cornwall - Startbar.co.uk

  • #2
    Senior Coder
    Join Date
    Dec 2002
    Location
    Arlington, Texas USA
    Posts
    1,072
    Thanks
    4
    Thanked 8 Times in 8 Posts
    Going to the documentation for what you need to enter will really help. it is really quite simple. here is a brief example sending the name and address


    html for page with form
    Code:
    <form method="post" action="send.asp">
    Name:<input type="text" name="PersonName">
    Address:<input type="text" name="PersonAddress">
    <input type="submit" name="cmdSubmit" value="Send Email">
    </form>
    send.asp page
    Code:
    <%
    Dim sMessage
    Dim Mailer
    sMessage = "Name: " & Request.Form("PersonName") & vbCrLf & "Address: " & Request.Form("PersonAddress")
    
    Set Mailer = Server.CreateObject("SMTPsvg.Mailer")
    Mailer.FromName   = Request.Form("PersonName")
    Mailer.FromAddress= "Webmaster@yoursite.com"
    Mailer.RemoteHost = "auth.smtp.1and1.co.uk "
    Mailer.AddRecipient "Your Name Here", "Your Email Address Here"
    Mailer.Subject    = "Web contact info"
    Mailer.BodyText   = sMessage
    if Mailer.SendMail then
      Response.Write "Mail sent..."
    else
      Response.Write "Mail send failure. Error was " & Mailer.Response
    end if
    Set Mailer = Nothing
    %>
    Last edited by miranda; 07-26-2007 at 11:42 PM.

  • #3
    New Coder
    Join Date
    May 2007
    Posts
    27
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I am trying to do something similar with this code, and I am a little confused on the sytax and placement of the code itself. I am using the "simple" version of ASPmail, and I was wondering about the error handling.

    In the code above, you just simply call Response.Write for the success or failure of the mail being sent. What I have is this:

    Code:
    strErr = ""
    bSuccess = False
    On Error Resume Next ' catch errors
    Mail.Send	 ' send message
    If Err <> 0 Then ' error occurred
    	strErr = Err.Description
    else
    	bSuccess = True
    End If
    This is the end of the code similar to your 'send.asp' page (mine is called confirmation.asp).

    My question is where would I put all of this code on my confirmation page? Should it be before any html, or after the body tag?

    Also, I want to print out the error/success message as follows:

    Code:
    <% If strErr <> "" Then %>
    <h3><div align="center"><FONT COLOR="#FF0000">Error occurred: <I><% = strErr %></I></FONT></div></h3>
    <% End If %>
    
    <% If bSuccess Then %>
    <h3>
    <div align="center"><FONT COLOR="#00A000">
    Thank you for registering, <% =Request.Form("name") %>!
    </FONT></div>
    </h3>
    <% End If %>
    For some reason this is not working. Even though my 'register.asp' form has 'action="confirmation.asp", the confirmation page never loads (as if it can not be found).

    Can you offer any help? thanks

  • #4
    Senior Coder
    Join Date
    Dec 2002
    Location
    Arlington, Texas USA
    Posts
    1,072
    Thanks
    4
    Thanked 8 Times in 8 Posts
    Quote Originally Posted by Punkcrib View Post
    My question is where would I put all of this code on my confirmation page? Should it be before any html, or after the body tag?
    If you want to display a message to the user, put that part after the HTML body tag. The rest of it can either go just above this or at the beginning of the page. All of the ASP code will process before the HTML code does. However, when you do a Response.Write the Response.Write will appear on the page just as it would if it were HTML or text. It all depends on where in your HTML you place it.

    Quote Originally Posted by Punkcrib View Post
    Also, I want to print out the error/success message as follows:
    Code:
    <% If strErr <> "" Then %>
    <h3><div align="center"><FONT COLOR="#FF0000">Error occurred: <I><% = strErr %></I></FONT></div></h3>
    <% End If %>
    
    <% If bSuccess Then %>
    <h3>
    <div align="center"><FONT COLOR="#00A000">
    Thank you for registering, <% =Request.Form("name") %>!
    </FONT></div>
    </h3>
    <% End If %>
    For some reason this is not working. Even though my 'register.asp' form has 'action="confirmation.asp", the confirmation page never loads (as if it can not be found).
    Does it return an error at all or just sit there? If it just sits there after the click of the button and you are using an input type=button instead of an input type=submit then most likely it is a problem with the client side javascript that handles the onClick event. If it returns an error - Does the page return a 404 error (File not found)? If that is the case and you are positive you have the path to the page specified correctly in the action attribute of the form tag, then you most likely have IE's friendly error messages turned on. Turn them off and see what the real error message is. You can turn them off through Internet Options click advanced tab (far right tab at the top) then scroll down under the Browsing heading and uncheck the box next to 'Show friendly HTTP error messages' click apply and then resubmit the form. you should now see what the real error message is.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •