Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How To Get Contact Form To Work

Status
Not open for further replies.

Petrolhead

Technical User
Mar 13, 2009
27
Hi there,

I'm creating a contact form for my website.

I have designed the form, but I'm not sure how to go about getting it to process the information and send it to me.

I guess I need to add some sort of script to the thank you page??

Can anyone help?

Code:
<div id="content">
 
<!-- Begin Main Page Content -->
<!-- main content section -->
 
<h1>
Contact
</h1>
<form method="POST" action="contact-info-thank-you.htm">
<table width="90%" cellspacing=5 cellpadding=5>
<tr>
<td align=left><b>Your name</b><br>
<input type="text" name="name" size=30 maxlength=50 id="name"></td>
</tr>

<tr>
<td align=left><b>Your email address</b><br>
<input type="text" name="email" size=30 maxlength=255 id="email"></td>
</tr>

<tr>
<td align=left><b>Message type</b><br>

<select name="subject"  id="subject">
<option value="Comment" selected>Feedback
<option value="Suggestion">Suggestion
<option value="Problem or typo">Problem or typo report
<option value="Other">Other
</select>
</td></tr>

<tr>
<td align=left><b>Your message</b><br>
<textarea cols="50" rows="5" name="Message"></textarea></td>
</tr>

<tr><td align=center colspan=2><input type="Submit" value="Submit Message"></td></tr>
</table>
</form>
<br>

</div>  <!-- content -->

Code:
<div id="content">
 
<!-- Begin Main Page Content -->
<!-- main content section -->
 
<h1>
Thank You!
</h1>

<p>
Thank you for contacting me.  All messages are read, and I will reply to you as soon as possible.
</p>

</div>  <!-- content -->
 
The question is what you want to do with the information from the form?

But yes you'll need a script likely.

So you need to tell us what programming languages are available to you and/or supported by the web server this is going to be hosted on.

Second is what kind of processing you want to have done?


----------------------------------
Phil AKA Vacunita
----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.
 
I want the information in the form to be e-mailed to me.

Preferrably the name, e-mail & subject selected in the form to appear as the name, from and subject on the e-mail so I can use the reply function.

I would prefer to use ASP, as it's closest to VBA which I have some background in.

I've been trying this script but it doesn't e-mail anything to me or display the success page.

Code:
<%

' declare variables
Dim EmailTo
Dim Subject
Dim Name
Dim Subject
Dim E-MailAddress
Dim Message

' get posted data into variables
EmailTo = "tirvine24@gmail.com"
Subject = Trim(Request.Form("Subject")) 
Name = Trim(Request.Form("Name"))  
E-MailAddress = Trim(Request.Form("Email")) 
Message = Trim(Request.Form("Message")) 

' validation
Dim validationOK
validationOK=true
If  (Trim(Name)="")  Then validationOK=false
If (Trim(Subject)="") Then validationOK=false
If (Trim(Email)="") Then validationOK=false
If (Trim(Message)="") Then validationOK=false
If (validationOK=false) Then Response.Redirect("error.htm")

' prepare email body text
Dim Body
Body = Body & "Name: " & Name & VbCrLf
Body = Body & "Subject: " & Subject & VbCrLf
Body = Body & "E-MailAddress: " & E-MailAddress & VbCrLf
Body = Body & "Message: " & Message & VbCrLf

' send email 
Dim mail
Set mail = Server.CreateObject("CDONTS.NewMail") 
mail.To = EmailTo
mail.Subject = Subject
mail.Body = Body
mail.Send 

' redirect to success page 
Response.Redirect("contact-info-thank-you.htm")
%>

I'd also prefer it if I could have these as required fields rather than having a separate error page, but I'm struggling here, bit out of my depth.
 
Well I''m really not very familiar with ASP, so I'll point you to the forum for ASP here at Tek-tips. I'm sure the guys there will be more than happy to help you fix your script to get it work.

forum333




----------------------------------
Phil AKA Vacunita
----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top