...

View Full Version : Contact form



startbar
07-26-2007, 07:49 PM
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

miranda
07-26-2007, 10:39 PM
Going to the documentation (http://www.serverobjects.com/comp/Aspmail4.htm) 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


<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


<%
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
%>

Punkcrib
08-01-2007, 02:49 PM
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:


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:


<% 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

miranda
08-01-2007, 07:49 PM
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.



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


<% 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.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum