Help?! ASP form has me boggled
http://www.zerocattle.com/examples/form_test.asp is the source code. It doesn't work on that server (obviously) because doesn't have ASP on it (Unix).
However, I need it to work on an NT server, and I need it to report, in order, the fields and the values of the fields, and mail the form results to me.
Please help! I have been over this a few times and I just can't wrap my head around VB. Perl, sure! But VB and ASP have me begging.
Thanks!
Suzanne
KLWong posted this at 17:09 — 30th October 2000.
They have: 135 posts
Joined: Apr 2000
If you're looking around for a free place to try out your ASP code, you might want to get a free account at http://www.brinkster.com. I'm the type of programmer who wants to try stuff out at each and every step to be sure I'm on the right track; this account makes a nice "sandbox" for me where I can run code experiments without affecting the hits & pageview stats at my real site. Their free account doesn't offer any ASP email services (like ASPmail, etc.), but you can at least try out form processing, like by putting up a mockup page stating "Here is the data that would be emailed to you:".
Kristen
http://www.RewardsLookup.com and
http://www.cancerdrugfeedback.net still under early development
Personal page:http://www.isd.net/kwong/kristen.html
Peter J. Boettcher posted this at 17:25 — 30th October 2000.
They have: 812 posts
Joined: Feb 2000
Suzanne,
It's a little hard to check your code since it word-wrapped but it looked ok to me. I'll print it out here and add anything I think you need.
Option Explicit
Dim oMail
Dim sCommentType
Dim sComments
Dim sName
Dim sEmail
Dim sTelephone
Dim sMessageBody 'get form values
sCommentType = Trim(Request.Form("radCommentType")) sComments = Trim(Request.Form("txtComments"))
sName = Trim(Request.Form("txtName"))
sEmail = Trim(Request.Form("txtEmail"))
sTelephone = Trim(Request.Form("txtTelephone"))
'if any values are blank, replace with "[Not Given]"
If sName = "" Then sName = "[Not Given]"
If sEmail = "" Then sEmail = "[Not Given]"
If sTelephone = "" Then sTelephone = "[Not Given]"
'DO ANY FORM CHECKING HERE BEFORE CONTINUING (Optional)
If sName = "[Not Given]" or sEmail = "[Not Given]" or sTelephone = "[Not Given]" Then
Session("ErrorMessage") = "You did not fill our a required field"
Response.Redirect "form.asp"
Else 'Go ahead and send email
'compose message body
sMessageBody = "Comment Type: " & sCommentType & VbCrLf
sMessageBody = sMessageBody & "Comments : " & sComments & VbCrLf
sMessageBody = sMessageBody & "Name : " & sName & VbCrLf
sMessageBody = sMessageBody & "EMail : " & sEmail & VbCrLf
sMessageBody = sMessageBody & "Telephone : " & sTelephone & VbCrLf
sMessageBody = sMessageBody & "-----END OF EMAIL-----"
'instantiate object
Set oMail = Server.CreateObject("CDONTS.Newmail")
'set parameters
oMail.To = 'recipients email address here
oMail.From = 'senders email address here
oMail.Subject = "Test"
oMail.MailFormat = 0 'plain text format
oMail.BodyFormat = 0 'plain text format
'assign message body
oMail.Body = sMessageBody
'send
oMail.Send
Set oMail = Nothing
Session("ConfirmMessage") = "Thank you for filling out the form"
Response.Redirect "form.asp"
End If
That's it, I removed the Sub since you don't really need it, even if the form is callng itself. I also added some form checking, just as an example, that way if you have a required field that has to be filled out you want get any blank values (remember JavaScript can always be turned off which disables client-side form checking).
For the CDONTS object to work you have to have SMTP server running on your IIS installation.
If you're still having trouble there's a good example at http://www.asp101.com
Regards,
Peter J. Boettcher
(Moderator edit: added code tags)
PJ | Are we there yet?
pjboettcher.com
Suzanne posted this at 19:35 — 30th October 2000.
She has: 5,507 posts
Joined: Feb 2000
okay, I haven't tried it yet, but a response is such a great thing. Thank you both for your response and suggestions, I am off and running again.
Much obliged!
Suzanne
Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.