Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
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 July 10th, 2003, 09:44 AM
Authorized User
 
Join Date: Jul 2003
Location: Houston, Texas, USA.
Posts: 38
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to nvillare
Default Submitting a form to a database

I am attempting to create an asp page where the user will sign a guest book. The page then validates the required fields, sends the information to the database and e-mails me the information to let me know a new entry has been inserted. I am doing this on brinkster and the only error message I get is "There is a problem with the page you are trying to reach and it cannot be displayed."

Here is my code--

<%@ Language=VBScript %>
<%
if isempty(Request.Form("Submit")) then
 'initial message to the user
 'listed in html part
 TheMessage1 = "Please use the form below to sign my guestbook."
 TheMessage2 = "Note that fields with * are required."
else
'temporary variables to hold the data
theName = Request.Form("theName")
Email = Request.Form("Email")
Location = Request.Form("Location")
Comments = Request.Form("Comments")

'check validation of Name
if isempty (Request.Form("theName")) or Request.Form("theName") = "" then
TheMessage1 = "The form was not submitted."
TheMessage2 = "Name is required!"

'check validation of email
elseif isempty(Request.Form("Email")) or Request.Form("Email") = "" then
 TheMessage1 = "The form was not submitted."
 TheMessage2 = "Email Address is required!"

elseif instr(Request.Form("Email", "@") = 0 or instr(Request.Form("Email"), ".") = 0 then
 TheMessage1 = "The form was not submitted."
 TheMessage2 = "Email address is invalid!"
end if

'connect to the database
set MyConn = Server.CreateObject ("ADODB.Connection")
MyConn.Open ("DRIVER={Microsoft Access Driver (*.mdb)}; DBQ="& Server.MapPath("\nvillare\db\nidia.mdb"))

'form has been submitted
ThanksMessage = "Thanks " & _
ThanksMessage = ThanksMessage & theName & _
ThanksMessage = ThanksMessage & "for signing my guestbook!"
TheMessage1 = cstr(ThanksMessage)
TheMessage2 = "Your entry will be reviewed prior to posting."

'combine the message to send to my email address
EmailMessage = "Sign-In entry to be reviewed for posting:" &
  '13 creates a new line in the message
  chr(13) & chr(13)
EmailMessage = EmailMessage & "Name: " & theName & chr(13)
EmailMessage = EmailMessage & "Email Address: " & Email & chr(13)
EmailMessage = EmailMessage & "Location: " & Location & chr(13)
EmailMessage = EmailMessage & "Comments: " & Comments & chr(13)

'set connection to email the message
set objMail = CreateObject("CDNTS.NewMail")
'send message to my email address
'parameter is to who, from, subject, message
objMail.Send "nidia_villarreal@oxy.com", Request.Form("Email"), _
"New Entry into the GuestBook!", cstr(EmailMessage)
'destroy the objMail
set objMail = nothing

'insert data into the database
MySQL = "INSERT INTO SignIn (theDate, theName, Email, Location, Comments)"
MySQL = MySQL & " VALUES ('" & Now() & "','"
MySQL = MySQL & theName &"','"
MySQL = MySQL & Email &"','"
MySQl = MySQL & Location &"','"
MySQL = MySQL & Comments &"')"

MyConn.Execute(MySQL)
MyConn.Close()
MyConn = null
%>

Any help os greatly appreciated!

Thanks!

Nidia
__________________
Thanks!

N
 
Old January 27th, 2005, 03:54 AM
Registered User
 
Join Date: Jan 2005
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I have a problem in submitting the form using vbscript

 
Old January 27th, 2005, 06:38 PM
Friend of Wrox
Points: 6,664, Level: 34
Points: 6,664, Level: 34 Points: 6,664, Level: 34 Points: 6,664, Level: 34
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2004
Location: Sydney, NSW, Australia.
Posts: 1,870
Thanks: 12
Thanked 20 Times in 20 Posts
Send a message via AIM to mat41
Default

;;;There is a problem with the page you are trying to reach and it cannot be displayed

That would be a Brinkster issue. You get what you pay for with them.

immanish

Your post is a bit lite to troubleshoot. BTW: forms get submitted using html


Wind is your friend
Matt




Similar Threads
Thread Thread Starter Forum Replies Last Post
form submitting cro_crx Pro PHP 5 January 25th, 2005 12:19 PM
Form Submitting cro_crx Beginning PHP 3 January 17th, 2005 01:30 PM
ASP code to update database on submitting form? kkbigal Classic ASP Databases 3 July 14th, 2003 05:55 AM





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