Active Server Pages Programming (ASP)/Contact form validation

Advertisement


Question
Hello

Iam very new to ASP. Here is my question:
1.) I have a contact.asp file which has a form with fields , Name, E-Mail, Address, Comments. ( a submit and reset button also)
2.)when the user fills the form and clicks submit the details should go to some e-mail address. How to do this?.
Please reply.

Answer
Hi

Here is the code make the necessary changes.

The first thing you need to do is create a formpage.asp page with the code below:

<form name="YourFormName" method="Post" action="confirmation.asp">
<table>
<tr><td>Email: </td>
<td><input type="text" name="Email" size="50"></td></tr>
<tr><td>First Name: </td>
<td><input type="text" name="FirstName" size="50"></td></tr>
<tr><td>Last Name: </td>
<td><input type="text" name="LastName" size="50"></td></tr>
<tr><td>Subject: </td>
<td><input type="text" name="Subject" size="50"></td></tr>
<tr><td>Comments: </td>
<td><textarea name="Comments"></textarea></td>
</table>
<input type="submit" name="Submit" value="Submit Form">
</form>


Next, we create a resultspage.asp page with our CDONTS code as seen below:

<%
DIM strEmail, strName, strComments, mail, reply, objMail
strEmail = request.form("Email")
strName = request.form("Name")
strComments = request.form("Comments")

mail = "YOUR EMAIL ADDRESS HERE"
reply = request.form("Email")
Set objMail = Server.CreateObject("CDONTS.NewMail")
objMail.From = reply
objMail.Subject = "YOUR SUBJECT MESSAGE HERE"
objMail.To = mail
objMail.Body = "Email: " & strEmail & vbCrLf & _
"Name: " & strName & vbCrLf & _
"Comments: " & vbCrLf & strComments

objMail.Send
Set objMail = nothing
%>

<P>
<%
strName = request.form("Name")
Response.Write strName
%>,</P>

<P>Thank you for emailing me.</P>



Happy Programming!

-Srini

Active Server Pages Programming (ASP)

All Answers


Answers by Expert:


Ask Experts

Volunteer


Srini Nagarajan

Expertise

I can answer any kind of questions in ASP.NET, C#, VB.NET, SharePoint 2007, ASP, Coldfusion, Powerbuilder 7.00 / 8.00, JAVA servlets, MS SQL 2000 / MSSQL7, Sybase

Experience

Contact me if you need any custom development on ASP.NET, ASP, SharePoint 2007, Coldfusion, Powerbuilder.

©2012 About.com, a part of The New York Times Company. All rights reserved.