Wrox Programmer Forums
|
Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." NOT for ASP.NET 1.0, 1.1, or 2.0
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 26th, 2010, 04:09 PM
Registered User
 
Join Date: Feb 2010
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Contact form with required fields

I have a contact form on my site (http://bigdogcattle.com/?a=Cattle_Contact) that uses a contact.asp.txt file to handle the input. Everything works fine except the required fields. I want an error to be generated what the required fields are not populated, but it isn't working. People can submit without filling any fields in. Any ideas? Here is the code for my contact.asp.txt file:


<%
' Website Contact Form Generator
' http://www.tele-pro.co.uk/scripts/contact_form/
' This script is free to use as long as you
' retain the credit link

' declare variables
Dim EmailFrom
Dim EmailTo
Dim Subject
Dim Name
Dim Address
Dim Telephone

' get posted data into variables
EmailFrom = Trim(Request.Form("EmailFrom"))
EmailTo = "[email protected]"
Subject = "Cattle Advertising"
Name = Trim(Request.Form("Name"))
Address = Trim(Request.Form("Address"))
Telephone = Trim(Request.Form("Telephone"))

' validation
Dim validationOK
validationOK=true
If (Trim(Telephone)="") Then validationOK=false
If (Trim(Name)="") Then validationOK=false
If (Trim(Address)="") Then validationOK=false
If (validationOK=false) Then Response.Redirect("error.htm?" & EmailFrom)

' prepare email body text
Dim Body
Body = Body & "Name: " & Name & VbCrLf
Body = Body & "Address: " & Address & VbCrLf
Body = Body & "Telephone: " & Telephone & VbCrLf

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

' redirect to success page
Response.Redirect("ok.htm?" & EmailFrom)
%>


Thanks

Jamie
 
Old February 26th, 2010, 06:26 PM
Friend of Wrox
 
Join Date: Jun 2008
Posts: 1,649
Thanks: 3
Thanked 141 Times in 140 Posts
Default

I don't understand how it does anything at all if it is named "contact.asp.txt". Only if it were named "contact.asp" would the web server even try to process it as an ASP file/page.

And the code *does* have validation in it:
Code:
If (validationOK=false) Then Response.Redirect("error.htm?" & EmailFrom)
My best guess is that you aren't showing us the actual code.

The <form> on your page posts right back to the same page:
Code:
<form method="post" action="">
(a blank action means "send the form to the same page").

And clearly the code you showed us is *NOT* the complete code for that page.





Similar Threads
Thread Thread Starter Forum Replies Last Post
I need help with contact form iorgusu Need help with your homework? 1 September 27th, 2009 01:56 AM
Contact form? philthy BOOK: ASP.NET MVC Website Programming Problem Design Solution ISBN: 9780470410950 1 July 23rd, 2009 05:14 PM
contact form Will BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 6 February 24th, 2009 01:42 PM
Resolved! - Verify Required fields and email form dartcoach HTML Code Clinic 25 April 28th, 2008 12:48 PM
Contact Form myself Classic ASP Basics 1 November 18th, 2006 11:16 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.