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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

fom validation, confirmation & e-mail results 1

Status
Not open for further replies.

5656

Technical User
Jan 6, 2001
68
US
Hello,
I'm just starting to play with ASP and would like to know if there's a simple explanation (or tutorial on the Web) that would help me create a script within an ASP page (that works in both IE and Netscape)that will:

>> VALIDATE MY FORM fields (communicating to user which
fields are in error)
>> E-MAIL form results TO my e-mail adrress
>> REDIRECT the user to a CONFIRMATION / THANKYOU
page upon successful completion of the form.

Any information would be most appreciated...
Thanks !!
 
Not sure but you better use JavaScript in your html code for this task...

Have Fun...Sharky99 >:):O>
 
You need to do the validation client-side (saves more trips to the server and back), the email can be sent with a mail component eg CDONTS, the redirect is just in the send mail page :

<%

'send mail
'script goes
'here

'when its
'finished

Response.Redirect &quot;my_redirect_page.asp&quot;
%> Regards

Big Dave

davidbyng@hotmail.com


** If I am wrong I am sorry, but i'm only trying to help!! **

 
Not sure if there is a place on the web but this might help.

1:create your form and post it to a page add this at the top of form page. call the page join.asp
<%@LANGUAGE=&quot;VBSCRIPT&quot;%>


<%Response.Expires = -1442%>
<%
fieldname=&quot;&quot; <---do this for all fields--->
%>
2:be sure to post it to a new page lets say joinadd.asp
3: now i use ASP mail you need to make sure its installed on the server its just a small programe.

4:now server side validation on joinadd.asp page
5:dim Email,Name
Name = Request.Form(&quot;Name&quot;)
Email = Request.Form(&quot;Email&quot;)

if Name = &quot;&quot; then
error = &quot;You have not entered a Name.please click back&quot;
Response.Write error
Response.End
end if

if Email = &quot;&quot; then
error = &quot;You have not entered an Email address.please click back&quot;
Response.Write error
Response.End
end if

6:you can do this for all fields.
7:now if good send mail
<%
Set mail = Server.CreateObject(&quot;Persits.Mailsender&quot;)
Mail.Host = &quot;a valid mail server.com&quot;



strName = request.form(&quot;Name&quot;)
strEamil = request.form('Email&quot;)


Mail.From = strEmail
Mail.FromName = strName
Mail.AddBCC &quot;&quot;
Mail.AddBCC &quot;&quot;
Mail.AddAddress strEmail
Mail.AddReplyTo strEmail
'Mail.AddAttachment &quot;c:\any file&quot;
strBodyHeader = &quot;Header&quot; & chr(13) & chr(10) & chr(13) & chr(10)
strBodyHeader = strBodyHeader & &quot;This is your Name : &quot; & strName & chr(13) & chr(10)
strBodyHeader = strBodyHeader & &quot;This is your Email address : &quot; & strEmail & chr(13) & chr(10)
strBody = strBodyHeader & strBody
Mail.Subject = &quot;Test&quot;
Mail.body = strBody
'Mail.Body = &quot;&quot; & Chr(13) & Chr(10) & &quot;


On Error Resume Next
Mail.Send
If Err <> 0 Then
Response.Write &quot;Error encountered: &quot; & Err.Description
End If
%>

Once we have sent the mail

<body bgcolor=&quot;#000000&quot; text=&quot;#FFFFFF&quot;>
<p align=&quot;center&quot;><font size=&quot;4&quot; color=&quot;#FFFFFF&quot;> <font size=&quot;7&quot;>Thank You </font></font>
<font color=&quot;#FFFFFF&quot; size=&quot;7&quot;><%
Dim strName
strName = Request.form(&quot;Name&quot;)
Response.Write strName
%></font></p>
<p align=&quot;center&quot;></p>
<div align=&quot;center&quot;> </div>
<div align=&quot;center&quot;>
<p><font color=&quot;#FFFFFF&quot;>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top